diff --git a/.ci/build_packages/Dockerfile b/.ci/build_packages/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6f9a12159d8405f41f0470174627d9598aa584b3 --- /dev/null +++ b/.ci/build_packages/Dockerfile @@ -0,0 +1,16 @@ +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 rm -rf _build/${EMQX_NAME}/lib _build/${EMQX_NAME}-pkg/lib + +RUN make ${EMQX_NAME}-zip || cat rebar3.crashdump + +RUN make ${EMQX_NAME}-pkg || cat rebar3.crashdump + +RUN /emqx/.ci/build_packages/tests.sh diff --git a/.ci/build_packages/tests.sh b/.ci/build_packages/tests.sh new file mode 100644 index 0000000000000000000000000000000000000000..68d8f2df20b704ec95052d2c415781cc32846057 --- /dev/null +++ b/.ci/build_packages/tests.sh @@ -0,0 +1,175 @@ +#!/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}/_upgrade_base" +# export EMQX_NODE_NAME="emqx-on-$(uname -m)@127.0.0.1" +# export EMQX_NODE_COOKIE=$(date +%s%N) + +case "$(uname -m)" in + x86_64) + ARCH='amd64' + ;; + aarch64) + ARCH='arm64' + ;; + arm*) + ARCH=arm + ;; +esac +export ARCH + +emqx_prepare(){ + mkdir -p "${PACKAGE_PATH}" + + if [ ! -d "/paho-mqtt-testing" ]; then + git clone -b develop-4.0 https://github.com/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 ! "${PACKAGE_PATH}"/emqx/bin/emqx_ctl status | grep -qE 'Node\s.*@.*\sis\sstarted' + 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 ! emqx_ctl status | grep -qE 'Node\s.*@.*\sis\sstarted' + 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 ! emqx_ctl status | grep -E 'Node\s.*@.*\sis\sstarted' + 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="$("$CODE_PATH"/pkg-vsn.sh)" + if [ -d "${RELUP_PACKAGE_PATH}" ];then + cd "${RELUP_PACKAGE_PATH}" + + find . -maxdepth 1 -name "${EMQX_NAME}-*-${ARCH}.zip" | + while read -r pkg; do + packagename=$(basename "${pkg}") + 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}-${ARCH}".zip ./emqx/releases + ./emqx/bin/emqx install "${TARGET_VERSION}" + [ "$(./emqx/bin/emqx versions |grep permanent | awk '{print $2}')" = "${TARGET_VERSION}" ] || exit 1 + ./emqx/bin/emqx_ctl status + ./emqx/bin/emqx stop + rm -rf emqx + done + fi +} + +emqx_prepare +emqx_test +relup_test diff --git a/.ci/docker-compose-file/.env b/.ci/docker-compose-file/.env new file mode 100644 index 0000000000000000000000000000000000000000..8c9d056cc8135f1e2f46802c0574f4abfc7bbaf7 --- /dev/null +++ b/.ci/docker-compose-file/.env @@ -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 diff --git a/.ci/docker-compose-file/conf.cluster.env b/.ci/docker-compose-file/conf.cluster.env new file mode 100644 index 0000000000000000000000000000000000000000..d8294a785e38aa4686124b4060b105b1df0f1916 --- /dev/null +++ b/.ci/docker-compose-file/conf.cluster.env @@ -0,0 +1,7 @@ +EMQX_NAME=emqx +EMQX_CLUSTER__DISCOVERY=static +EMQX_CLUSTER__STATIC__SEEDS="emqx@node1.emqx.io, emqx@node2.emqx.io" +EMQX_LISTENER__TCP__EXTERNAL__PROXY_PROTOCOL=on +EMQX_LISTENER__WS__EXTERNAL__PROXY_PROTOCOL=on +EMQX_LOG__LEVEL=debug +EMQX_LOADED_PLUGINS=emqx_sn diff --git a/.ci/docker-compose-file/conf.env b/.ci/docker-compose-file/conf.env new file mode 100644 index 0000000000000000000000000000000000000000..93dfecd2b6f4a421f210dab3b05dce7f5c0a5e9e --- /dev/null +++ b/.ci/docker-compose-file/conf.env @@ -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_ diff --git a/.ci/docker-compose-file/docker-compose-emqx-cluster.yaml b/.ci/docker-compose-file/docker-compose-emqx-cluster.yaml new file mode 100644 index 0000000000000000000000000000000000000000..18e1bb6cc458c97268ecccae42807f0b8627955f --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-emqx-cluster.yaml @@ -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 diff --git a/.ci/docker-compose-file/docker-compose-ldap-tcp.yaml b/.ci/docker-compose-file/docker-compose-ldap-tcp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..61eab91ecf5c985019f7e8b656e33ee18d43e8d6 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-ldap-tcp.yaml @@ -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 diff --git a/.ci/docker-compose-file/docker-compose-mongo-tcp.yaml b/.ci/docker-compose-file/docker-compose-mongo-tcp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dee2daff6ab9ffd22c2b95f472636583c0ac2b16 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-mongo-tcp.yaml @@ -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 diff --git a/.ci/docker-compose-file/docker-compose-mongo-tls.yaml b/.ci/docker-compose-file/docker-compose-mongo-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a09bc803d9489c75dd2f4d858803625c73a38215 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-mongo-tls.yaml @@ -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 diff --git a/.ci/docker-compose-file/docker-compose-mysql-tcp.yaml b/.ci/docker-compose-file/docker-compose-mysql-tcp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..70cc3d242f5391b0997dd1f4faf1c23f858105ca --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-mysql-tcp.yaml @@ -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 diff --git a/.ci/docker-compose-file/docker-compose-mysql-tls.yaml b/.ci/docker-compose-file/docker-compose-mysql-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c4d5bd5008ae0b6205b0d4ac1d57954e9a7b6b0b --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-mysql-tls.yaml @@ -0,0 +1,45 @@ +version: '3.9' + +services: + mysql_server: + container_name: mysql + image: mysql:${MYSQL_TAG} + restart: always + environment: + MYSQL_ROOT_PASSWORD: public + MYSQL_DATABASE: mqtt + MYSQL_USER: ssluser + MYSQL_PASSWORD: public + volumes: + - ../../apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/ca.pem:/etc/certs/ca-cert.pem + - ../../apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/server-cert.pem:/etc/certs/server-cert.pem + - ../../apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/server-key.pem:/etc/certs/server-key.pem + 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 + --ssl-ca=/etc/certs/ca-cert.pem + --ssl-cert=/etc/certs/server-cert.pem + --ssl-key=/etc/certs/server-key.pem + + mysql_client: + container_name: mysql_client + image: mysql:${MYSQL_TAG} + networks: + - emqx_bridge + depends_on: + - mysql_server + command: + - /bin/bash + - -c + - | + service mysql start + echo "show tables;" | mysql -h mysql_server -u root -ppublic mqtt mqtt + while [[ $$? -ne 0 ]];do echo "show tables;" | mysql -h mysql_server -u root -ppublic mqtt; done + echo "ALTER USER 'ssluser'@'%' REQUIRE X509;" | mysql -h mysql_server -u root -ppublic mqtt diff --git a/.ci/docker-compose-file/docker-compose-pgsql-tcp.yaml b/.ci/docker-compose-file/docker-compose-pgsql-tcp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..111209644cb0486bcd0db08925f0c446d8992d2a --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-pgsql-tcp.yaml @@ -0,0 +1,15 @@ +version: '3.9' + +services: + pgsql_server: + container_name: pgsql + image: postgres:${PGSQL_TAG} + restart: always + environment: + POSTGRES_PASSWORD: public + POSTGRES_USER: root + POSTGRES_DB: mqtt + ports: + - "5432:5432" + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose-pgsql-tls.yaml b/.ci/docker-compose-file/docker-compose-pgsql-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..72aceed6907d4643a8dba5b35f22431a41224f49 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-pgsql-tls.yaml @@ -0,0 +1,32 @@ +version: '3.9' + +services: + pgsql_server: + container_name: pgsql + build: + context: ../.. + dockerfile: .ci/docker-compose-file/pgsql/Dockerfile + args: + POSTGRES_USER: postgres + BUILD_FROM: postgres:${PGSQL_TAG} + image: emqx_pgsql:${PGSQL_TAG} + restart: always + environment: + POSTGRES_DB: mqtt + POSTGRES_USER: root + POSTGRES_PASSWORD: public + ports: + - "5432:5432" + command: + - -c + - ssl=on + - -c + - ssl_cert_file=/var/lib/postgresql/server.crt + - -c + - ssl_key_file=/var/lib/postgresql/server.key + - -c + - ssl_ca_file=/var/lib/postgresql/root.crt + - -c + - hba_file=/var/lib/postgresql/pg_hba.conf + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose-python.yaml b/.ci/docker-compose-file/docker-compose-python.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0b9af4517c299e038db602febb8e8484171004f3 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-python.yaml @@ -0,0 +1,15 @@ +version: '3.9' + +services: + python: + container_name: python + image: python:3.7.2-alpine3.9 + depends_on: + - emqx1 + - emqx2 + tty: true + networks: + emqx_bridge: + volumes: + - ./python:/scripts + diff --git a/.ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml b/.ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..997388aa537d7edb8aa235849b3f13afccebec9b --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml @@ -0,0 +1,11 @@ +version: '3.9' + +services: + redis_server: + image: redis:${REDIS_TAG} + container_name: redis + volumes: + - ./redis/:/data/conf + command: bash -c "/bin/bash /data/conf/redis.sh --node cluster && tail -f /var/log/redis-server.log" + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml b/.ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..78b6559463cf142cd1e49df209d03832d690cfec --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml @@ -0,0 +1,12 @@ +version: '3.9' + +services: + redis_server: + container_name: redis + image: redis:${REDIS_TAG} + volumes: + - ../../apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs:/tls + - ./redis/:/data/conf + command: bash -c "/bin/bash /data/conf/redis.sh --node cluster --tls-enabled && tail -f /var/log/redis-server.log" + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml b/.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1cdd28726032e1dfc0b99a7fc01b6b98dff56c34 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml @@ -0,0 +1,11 @@ +version: '3.9' + +services: + redis_server: + container_name: redis + image: redis:${REDIS_TAG} + volumes: + - ./redis/:/data/conf + command: bash -c "/bin/bash /data/conf/redis.sh --node sentinel && tail -f /var/log/redis-server.log" + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose-redis-sentinel-tls.yaml b/.ci/docker-compose-file/docker-compose-redis-sentinel-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7c7f46ce20b1fffae2052bc6e2a84669ee4927a8 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-sentinel-tls.yaml @@ -0,0 +1,12 @@ +version: '3.9' + +services: + redis_server: + container_name: redis + image: redis:${REDIS_TAG} + volumes: + - ../../apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs:/tls + - ./redis/:/data/conf + command: bash -c "/bin/bash /data/conf/redis.sh --node sentinel --tls-enabled && tail -f /var/log/redis-server.log" + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose-redis-single-tcp.yaml b/.ci/docker-compose-file/docker-compose-redis-single-tcp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..92a3fcf7df0221d04bfb5b23477c3c05d8cdc5a9 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-single-tcp.yaml @@ -0,0 +1,13 @@ +version: '3.9' + +services: + redis_server: + container_name: redis + image: redis:${REDIS_TAG} + command: + - redis-server + - "--bind 0.0.0.0 ::" + - --requirepass public + restart: always + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose-redis-single-tls.yaml b/.ci/docker-compose-file/docker-compose-redis-single-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..814a0f1cb5b6cbcee5f35d3fc46732b73ad83876 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-single-tls.yaml @@ -0,0 +1,19 @@ +version: '3.9' + +services: + redis_server: + container_name: redis + image: redis:${REDIS_TAG} + volumes: + - ../../apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs:/tls + command: + - redis-server + - "--bind 0.0.0.0 ::" + - --requirepass public + - --tls-port 6380 + - --tls-cert-file /tls/redis.crt + - --tls-key-file /tls/redis.key + - --tls-ca-cert-file /tls/ca.crt + restart: always + networks: + - emqx_bridge diff --git a/.ci/docker-compose-file/docker-compose.yaml b/.ci/docker-compose-file/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a502aeb6e80408abf93e0ec48d9f0846894b093f --- /dev/null +++ b/.ci/docker-compose-file/docker-compose.yaml @@ -0,0 +1,35 @@ +version: '3.9' + +services: + erlang: + container_name: erlang + image: emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04 + env_file: + - conf.env + environment: + GITHUB_ACTIONS: ${GITHUB_ACTIONS} + GITHUB_TOKEN: ${GITHUB_TOKEN} + GITHUB_RUN_ID: ${GITHUB_RUN_ID} + GITHUB_SHA: ${GITHUB_SHA} + GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER} + GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME} + GITHUB_REF: ${GITHUB_REF} + networks: + - emqx_bridge + volumes: + - ../..:/emqx + working_dir: /emqx + tty: true + +networks: + emqx_bridge: + driver: bridge + name: emqx_bridge + enable_ipv6: true + ipam: + driver: default + config: + - subnet: 172.100.239.0/24 + gateway: 172.100.239.1 + - subnet: 2001:3200:3200::/64 + gateway: 2001:3200:3200::1 diff --git a/.ci/docker-compose-file/haproxy/haproxy.cfg b/.ci/docker-compose-file/haproxy/haproxy.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73c219d554d1e78fbba461585b3e3f1ed06451f1 --- /dev/null +++ b/.ci/docker-compose-file/haproxy/haproxy.cfg @@ -0,0 +1,109 @@ +##---------------------------------------------------------------- +## global 2021/04/05 +##---------------------------------------------------------------- +global + log stdout format raw daemon debug + # Replace 1024000 with deployment connections + maxconn 1000 + nbproc 1 + nbthread 2 + cpu-map auto:1/1-2 0-1 + tune.ssl.default-dh-param 2048 + ssl-default-bind-ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP + # Enable the HAProxy Runtime API + stats socket :9999 level admin expose-fd listeners + +##---------------------------------------------------------------- +## defaults +##---------------------------------------------------------------- +defaults + log global + mode tcp + option tcplog + # Replace 1024000 with deployment connections + maxconn 1000 + timeout connect 30000 + timeout client 600s + timeout server 600s + +##---------------------------------------------------------------- +## API +##---------------------------------------------------------------- +frontend emqx_mgmt + mode tcp + option tcplog + bind *:8081 + default_backend emqx_mgmt_back + +frontend emqx_dashboard + mode tcp + option tcplog + bind *:18083 + default_backend emqx_dashboard_back + +backend emqx_mgmt_back + mode http + # balance static-rr + server emqx-1 node1.emqx.io:8081 + server emqx-2 node2.emqx.io:8081 + +backend emqx_dashboard_back + mode http + # balance static-rr + server emqx-1 node1.emqx.io:18083 + server emqx-2 node2.emqx.io:18083 + + +##---------------------------------------------------------------- +## public +##---------------------------------------------------------------- +frontend emqx_tcp + mode tcp + option tcplog + bind *:1883 + default_backend emqx_tcp_back + +frontend emqx_ws + mode tcp + option tcplog + bind *:8083 + default_backend emqx_ws_back + +backend emqx_tcp_back + mode tcp + balance static-rr + server emqx-1 node1.emqx.io:1883 check-send-proxy send-proxy-v2 + server emqx-2 node2.emqx.io:1883 check-send-proxy send-proxy-v2 + +backend emqx_ws_back + mode tcp + balance static-rr + server emqx-1 node1.emqx.io:8083 check-send-proxy send-proxy-v2 + server emqx-2 node2.emqx.io:8083 check-send-proxy send-proxy-v2 + +##---------------------------------------------------------------- +## TLS +##---------------------------------------------------------------- +frontend emqx_ssl + mode tcp + option tcplog + bind *:8883 ssl crt /usr/local/etc/haproxy/certs/emqx.pem ca-file /usr/local/etc/haproxy/certs/cacert.pem verify required no-sslv3 + default_backend emqx_ssl_back + +frontend emqx_wss + mode tcp + option tcplog + bind *:8084 ssl crt /usr/local/etc/haproxy/certs/emqx.pem ca-file /usr/local/etc/haproxy/certs/cacert.pem verify required no-sslv3 + default_backend emqx_wss_back + +backend emqx_ssl_back + mode tcp + balance static-rr + server emqx-1 node1.emqx.io:1883 check-send-proxy send-proxy-v2-ssl-cn + server emqx-2 node2.emqx.io:1883 check-send-proxy send-proxy-v2-ssl-cn + +backend emqx_wss_back + mode tcp + balance static-rr + server emqx-1 node1.emqx.io:8083 check-send-proxy send-proxy-v2-ssl-cn + server emqx-2 node2.emqx.io:8083 check-send-proxy send-proxy-v2-ssl-cn diff --git a/.ci/docker-compose-file/openldap/Dockerfile b/.ci/docker-compose-file/openldap/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..adbb808008bdae77eece7b86d36c8f762ca7bdab --- /dev/null +++ b/.ci/docker-compose-file/openldap/Dockerfile @@ -0,0 +1,26 @@ +FROM buildpack-deps:stretch + +ARG LDAP_TAG=2.4.50 + +RUN apt-get update && apt-get install -y groff groff-base +RUN wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-${LDAP_TAG}.tgz \ + && gunzip -c openldap-${LDAP_TAG}.tgz | tar xvfB - \ + && cd openldap-${LDAP_TAG} \ + && ./configure && make depend && make && make install \ + && cd .. && rm -rf openldap-${LDAP_TAG} + +COPY .ci/docker-compose-file/openldap/slapd.conf /usr/local/etc/openldap/slapd.conf +COPY apps/emqx_auth_ldap/emqx.io.ldif /usr/local/etc/openldap/schema/emqx.io.ldif +COPY apps/emqx_auth_ldap/emqx.schema /usr/local/etc/openldap/schema/emqx.schema +COPY apps/emqx_auth_ldap/test/certs/*.pem /usr/local/etc/openldap/ + +RUN mkdir -p /usr/local/etc/openldap/data \ + && slapadd -l /usr/local/etc/openldap/schema/emqx.io.ldif -f /usr/local/etc/openldap/slapd.conf + +WORKDIR /usr/local/etc/openldap + +EXPOSE 389 636 + +ENTRYPOINT ["/usr/local/libexec/slapd", "-h", "ldap:/// ldaps:///", "-d", "3", "-f", "/usr/local/etc/openldap/slapd.conf"] + +CMD [] diff --git a/.ci/docker-compose-file/openldap/slapd.conf b/.ci/docker-compose-file/openldap/slapd.conf new file mode 100644 index 0000000000000000000000000000000000000000..d6ba20caa5e4c2bde9e7d43b8a484af7ccb799a0 --- /dev/null +++ b/.ci/docker-compose-file/openldap/slapd.conf @@ -0,0 +1,16 @@ +include /usr/local/etc/openldap/schema/core.schema +include /usr/local/etc/openldap/schema/cosine.schema +include /usr/local/etc/openldap/schema/inetorgperson.schema +include /usr/local/etc/openldap/schema/ppolicy.schema +include /usr/local/etc/openldap/schema/emqx.schema + +TLSCACertificateFile /usr/local/etc/openldap/cacert.pem +TLSCertificateFile /usr/local/etc/openldap/cert.pem +TLSCertificateKeyFile /usr/local/etc/openldap/key.pem + +database bdb +suffix "dc=emqx,dc=io" +rootdn "cn=root,dc=emqx,dc=io" +rootpw {SSHA}eoF7NhNrejVYYyGHqnt+MdKNBh4r1w3W + +directory /usr/local/etc/openldap/data diff --git a/.ci/docker-compose-file/pgsql/Dockerfile b/.ci/docker-compose-file/pgsql/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e4c9732589eb005141724e116f44a9d2a05fcbaa --- /dev/null +++ b/.ci/docker-compose-file/pgsql/Dockerfile @@ -0,0 +1,12 @@ +ARG BUILD_FROM=postgres:11 +FROM ${BUILD_FROM} +ARG POSTGRES_USER=postgres +COPY --chown=$POSTGRES_USER .ci/docker-compose-file/pgsql/pg_hba.conf /var/lib/postgresql/pg_hba.conf +COPY --chown=$POSTGRES_USER apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/server-key.pem /var/lib/postgresql/server.key +COPY --chown=$POSTGRES_USER apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/server-cert.pem /var/lib/postgresql/server.crt +COPY --chown=$POSTGRES_USER apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/ca.pem /var/lib/postgresql/root.crt +RUN chmod 600 /var/lib/postgresql/pg_hba.conf +RUN chmod 600 /var/lib/postgresql/server.key +RUN chmod 600 /var/lib/postgresql/server.crt +RUN chmod 600 /var/lib/postgresql/root.crt +EXPOSE 5432 diff --git a/.ci/docker-compose-file/pgsql/pg_hba.conf b/.ci/docker-compose-file/pgsql/pg_hba.conf new file mode 100644 index 0000000000000000000000000000000000000000..8b4f9b5a6519cf40a7ba1a60426566704684fced --- /dev/null +++ b/.ci/docker-compose-file/pgsql/pg_hba.conf @@ -0,0 +1,9 @@ +# TYPE DATABASE USER CIDR-ADDRESS METHOD +local all all trust +host all all 0.0.0.0/0 trust +host all all ::/0 trust +hostssl all all 0.0.0.0/0 cert +hostssl all all ::/0 cert + +hostssl all www-data 0.0.0.0/0 cert clientcert=1 +hostssl all postgres 0.0.0.0/0 cert clientcert=1 diff --git a/.ci/docker-compose-file/python/pytest.sh b/.ci/docker-compose-file/python/pytest.sh new file mode 100644 index 0000000000000000000000000000000000000000..eacbecc3b1bbc8cb23804df96921d02a6f1f363d --- /dev/null +++ b/.ci/docker-compose-file/python/pytest.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +## This script is to run emqx cluster smoke tests (fvt) in github action +## This script is executed in pacho_client + +set -x +set +e + +LB="haproxy" + +apk update && apk add git curl +git clone -b develop-4.0 https://github.com/emqx/paho.mqtt.testing.git /paho.mqtt.testing +pip install pytest + +pytest -v /paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "$LB" +RESULT=$? + +pytest -v /paho.mqtt.testing/interoperability/test_client --host "$LB" +RESULT=$(( RESULT + $? )) + +# pytest -v /paho.mqtt.testing/interoperability/test_cluster --host1 "node1.emqx.io" --host2 "node2.emqx.io" +# RESULT=$(( RESULT + $? )) + +exit $RESULT diff --git a/.ci/docker-compose-file/redis/redis-tls.conf b/.ci/docker-compose-file/redis/redis-tls.conf new file mode 100644 index 0000000000000000000000000000000000000000..325c200c3c42ef0e5928362fa47aa1e12d2efe92 --- /dev/null +++ b/.ci/docker-compose-file/redis/redis-tls.conf @@ -0,0 +1,11 @@ +daemonize yes +bind 0.0.0.0 :: +logfile /var/log/redis-server.log +tls-cert-file /tls/redis.crt +tls-key-file /tls/redis.key +tls-ca-cert-file /tls/ca.crt +tls-replication yes +tls-cluster yes +protected-mode no +requirepass public +masterauth public diff --git a/.ci/docker-compose-file/redis/redis.conf b/.ci/docker-compose-file/redis/redis.conf new file mode 100644 index 0000000000000000000000000000000000000000..6181925db8efc51cccdd9fa6d85f926fcef344e1 --- /dev/null +++ b/.ci/docker-compose-file/redis/redis.conf @@ -0,0 +1,5 @@ +daemonize yes +bind 0.0.0.0 :: +logfile /var/log/redis-server.log +requirepass public +masterauth public diff --git a/.ci/docker-compose-file/redis/redis.sh b/.ci/docker-compose-file/redis/redis.sh new file mode 100644 index 0000000000000000000000000000000000000000..272a5b44388fab6ee42b8f8b33302be63994cbd0 --- /dev/null +++ b/.ci/docker-compose-file/redis/redis.sh @@ -0,0 +1,125 @@ +#!/bin/bash + +set -x + +LOCAL_IP=$(hostname -i | grep -oE '((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])\.){3}(25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])' | head -n 1) + +node=single +tls=false +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -n|--node) + node="$2" + shift # past argument + shift # past value + ;; + -t|--tls-enabled) + tls="$2" + shift # past argument + shift # past value + ;; + *) + shift # past argument + ;; +esac +done + +rm -f \ + /data/conf/r7000i.log \ + /data/conf/r7001i.log \ + /data/conf/r7002i.log \ + /data/conf/nodes.7000.conf \ + /data/conf/nodes.7001.conf \ + /data/conf/nodes.7002.conf ; + +if [ "${node}" = "cluster" ] ; then + if $tls ; then + redis-server /data/conf/redis-tls.conf --port 7000 --cluster-config-file /data/conf/nodes.7000.conf \ + --tls-port 8000 --cluster-enabled yes ; + redis-server /data/conf/redis-tls.conf --port 7001 --cluster-config-file /data/conf/nodes.7001.conf \ + --tls-port 8001 --cluster-enabled yes; + redis-server /data/conf/redis-tls.conf --port 7002 --cluster-config-file /data/conf/nodes.7002.conf \ + --tls-port 8002 --cluster-enabled yes; + else + redis-server /data/conf/redis.conf --port 7000 --cluster-config-file /data/conf/nodes.7000.conf --cluster-enabled yes; + redis-server /data/conf/redis.conf --port 7001 --cluster-config-file /data/conf/nodes.7001.conf --cluster-enabled yes; + redis-server /data/conf/redis.conf --port 7002 --cluster-config-file /data/conf/nodes.7002.conf --cluster-enabled yes; + fi +elif [ "${node}" = "sentinel" ] ; then + if $tls ; then + redis-server /data/conf/redis-tls.conf --port 7000 --cluster-config-file /data/conf/nodes.7000.conf \ + --tls-port 8000 --cluster-enabled no; + redis-server /data/conf/redis-tls.conf --port 7001 --cluster-config-file /data/conf/nodes.7001.conf \ + --tls-port 8001 --cluster-enabled no --slaveof "$LOCAL_IP" 8000; + redis-server /data/conf/redis-tls.conf --port 7002 --cluster-config-file /data/conf/nodes.7002.conf \ + --tls-port 8002 --cluster-enabled no --slaveof "$LOCAL_IP" 8000; + + else + redis-server /data/conf/redis.conf --port 7000 --cluster-config-file /data/conf/nodes.7000.conf \ + --cluster-enabled no; + redis-server /data/conf/redis.conf --port 7001 --cluster-config-file /data/conf/nodes.7001.conf \ + --cluster-enabled no --slaveof "$LOCAL_IP" 7000; + redis-server /data/conf/redis.conf --port 7002 --cluster-config-file /data/conf/nodes.7002.conf \ + --cluster-enabled no --slaveof "$LOCAL_IP" 7000; + fi +fi +REDIS_LOAD_FLG=true; + +while $REDIS_LOAD_FLG; +do + sleep 1; + redis-cli --pass public --no-auth-warning -p 7000 info 1> /data/conf/r7000i.log 2> /dev/null; + if [ -s /data/conf/r7000i.log ]; then + : + else + continue; + fi + redis-cli --pass public --no-auth-warning -p 7001 info 1> /data/conf/r7001i.log 2> /dev/null; + if [ -s /data/conf/r7001i.log ]; then + : + else + continue; + fi + redis-cli --pass public --no-auth-warning -p 7002 info 1> /data/conf/r7002i.log 2> /dev/null; + if [ -s /data/conf/r7002i.log ]; then + : + else + continue; + fi + if [ "${node}" = "cluster" ] ; then + if $tls ; then + yes "yes" | redis-cli --cluster create "$LOCAL_IP:8000" "$LOCAL_IP:8001" "$LOCAL_IP:8002" --pass public --no-auth-warning --tls true --cacert /tls/ca.crt --cert /tls/redis.crt --key /tls/redis.key; + else + yes "yes" | redis-cli --cluster create "$LOCAL_IP:7000" "$LOCAL_IP:7001" "$LOCAL_IP:7002" --pass public --no-auth-warning; + fi + elif [ "${node}" = "sentinel" ] ; then + tee /_sentinel.conf>/dev/null << EOF +port 26379 +bind 0.0.0.0 :: +daemonize yes +logfile /var/log/redis-server.log +dir /tmp +EOF + if $tls ; then + cat >>/_sentinel.conf<>/_sentinel.conf< http_server:start(). +Start http_server listener on 8080 successfully. +ok +2> http_server:stop(). +ok +``` + +### APIS + ++ GET `/counter` + + 返回计数器的值 + ++ POST `/counter` + + 计数器加一 + diff --git a/.ci/fvt_tests/http_server/rebar.config b/.ci/fvt_tests/http_server/rebar.config new file mode 100644 index 0000000000000000000000000000000000000000..259f235225fa3d81789bf8a3debc3fe5ea875f8d --- /dev/null +++ b/.ci/fvt_tests/http_server/rebar.config @@ -0,0 +1,10 @@ +{erl_opts, [debug_info]}. +{deps, + [ + {minirest, {git, "https://github.com.cnpmjs.org/emqx/minirest.git", {tag, "0.3.1"}}} + ]}. + +{shell, [ + % {config, "config/sys.config"}, + {apps, [http_server]} +]}. diff --git a/.ci/fvt_tests/http_server/src/http_server.app.src b/.ci/fvt_tests/http_server/src/http_server.app.src new file mode 100644 index 0000000000000000000000000000000000000000..f351bb349cfe7373e4365970bf1030583f4d6610 --- /dev/null +++ b/.ci/fvt_tests/http_server/src/http_server.app.src @@ -0,0 +1,17 @@ +{application, http_server, + [{description, "An OTP application"}, + {vsn, "0.1.0"}, + {registered, []}, + % {mod, {http_server_app, []}}, + {modules, []}, + {applications, + [kernel, + stdlib, + minirest + ]}, + {env,[]}, + {modules, []}, + + {licenses, ["Apache 2.0"]}, + {links, []} + ]}. diff --git a/.ci/fvt_tests/http_server/src/http_server.erl b/.ci/fvt_tests/http_server/src/http_server.erl new file mode 100644 index 0000000000000000000000000000000000000000..b66b7293946aafdf829d4b3d950578ac4b8af6b0 --- /dev/null +++ b/.ci/fvt_tests/http_server/src/http_server.erl @@ -0,0 +1,50 @@ +-module(http_server). + +-import(minirest, [ return/0 + , return/1 + ]). + +-export([ start/0 + , stop/0 + ]). + +-rest_api(#{ name => get_counter + , method => 'GET' + , path => "/counter" + , func => get_counter + , descr => "Check counter" + }). +-rest_api(#{ name => add_counter + , method => 'POST' + , path => "/counter" + , func => add_counter + , descr => "Counter plus one" + }). + +-export([ get_counter/2 + , add_counter/2 + ]). + +start() -> + application:ensure_all_started(minirest), + ets:new(relup_test_message, [named_table, public]), + Handlers = [{"/", minirest:handler(#{modules => [?MODULE]})}], + Dispatch = [{"/[...]", minirest, Handlers}], + minirest:start_http(?MODULE, #{socket_opts => [inet, {port, 8080}]}, Dispatch). + +stop() -> + ets:delete(relup_test_message), + minirest:stop_http(?MODULE). + +get_counter(_Binding, _Params) -> + return({ok, ets:info(relup_test_message, size)}). + +add_counter(_Binding, Params) -> + case lists:keymember(<<"payload">>, 1, Params) of + true -> + {value, {<<"id">>, ID}, Params1} = lists:keytake(<<"id">>, 1, Params), + ets:insert(relup_test_message, {ID, Params1}); + _ -> + ok + end, + return(). diff --git a/.ci/fvt_tests/relup.lux b/.ci/fvt_tests/relup.lux new file mode 100644 index 0000000000000000000000000000000000000000..462da9ea8ebe12f900aa40e52f65d35d92a27717 --- /dev/null +++ b/.ci/fvt_tests/relup.lux @@ -0,0 +1,188 @@ +[config var=PROFILE] +[config var=PACKAGE_PATH] +[config var=BENCH_PATH] +[config var=ONE_MORE_EMQX_PATH] +[config var=VSN] +[config var=OLD_VSNS] + +[config shell_cmd=/bin/bash] +[config timeout=600000] + +[loop old_vsn $OLD_VSNS] + +[shell http_server] + !cd http_server + !rebar3 shell + ???Eshell + ???> + !http_server:start(). + ?Start http_server listener on 8080 successfully. + ?ok + ?> + +[shell emqx] + !cd $PACKAGE_PATH + !unzip -q -o $PROFILE-ubuntu20.04-$(echo $old_vsn | sed -r 's/[v|e]//g')-amd64.zip + ?SH-PROMPT + + !cd emqx + !export EMQX_LOG__CONSOLE_HANDLER__ENABLE=true + !export EMQX_LOG__CONSOLE_HANDLER__LEVEL=debug + !export EMQX_LOG__PRIMARY_LEVEL=debug + !export EMQX_ZONES__DEFAULT__LISTENERS__MQTT_WSS__BIND="0.0.0.0:8085" + + !./bin/emqx start + ?EMQ X .* is started successfully! + ?SH-PROMPT + +[shell emqx2] + !cd $PACKAGE_PATH + !cp -f $ONE_MORE_EMQX_PATH/one_more_$(echo $PROFILE | sed 's/-/_/g').sh . + !./one_more_$(echo $PROFILE | sed 's/-/_/g').sh emqx2 + ?SH-PROMPT + !cd emqx2 + + !export EMQX_LOG__CONSOLE_HANDLER__ENABLE=true + !export EMQX_LOG__CONSOLE_HANDLER__LEVEL=debug + !export EMQX_LOG__PRIMARY_LEVEL=debug + + !./bin/emqx start + ?EMQ X .* is started successfully! + ?SH-PROMPT + + !./bin/emqx_ctl cluster join emqx@127.0.0.1 + ???Join the cluster successfully. + ?SH-PROMPT + + !./bin/emqx_ctl cluster status + """??? + Cluster status: #{running_nodes => ['emqx2@127.0.0.1','emqx@127.0.0.1'], + stopped_nodes => []} + """ + ?SH-PROMPT + + !./bin/emqx_ctl resources create 'web_hook' -i 'resource:691c29ba' -c '{"url": "http://127.0.0.1:8080/counter", "method": "POST"}' + ?created + ?SH-PROMPT + !./bin/emqx_ctl rules create 'SELECT * FROM "t/#"' '[{"name":"data_to_webserver", "params": {"$$resource": "resource:691c29ba"}}]' + ?created + ?SH-PROMPT + +[shell emqx] + !./bin/emqx_ctl resources list + ?691c29ba + ?SH-PROMPT + !./bin/emqx_ctl rules list + ?691c29ba + ?SH-PROMPT + +[shell bench] + !cd $BENCH_PATH + + !./emqtt_bench pub -c 10 -I 1000 -t t/%i -s 64 -L 300 + ???sent + +[shell emqx] + !echo "" > log/emqx.log.1 + ?SH-PROMPT + + !cp -f ../$PROFILE-ubuntu20.04-$VSN-amd64.zip releases/ + + !./bin/emqx install $VSN + ?Made release permanent: "$VSN" + ?SH-PROMPT + + !./bin/emqx versions |grep permanent + ?(.*)$VSN + ?SH-PROMPT + + !./bin/emqx_ctl cluster status + """??? + Cluster status: #{running_nodes => ['emqx2@127.0.0.1','emqx@127.0.0.1'], + stopped_nodes => []} + """ + ?SH-PROMPT + + !./bin/emqx_ctl plugins list | grep emqx_management + ?Plugin\(emqx_management.*active=true\) + ?SH-PROMPT + +[shell emqx2] + !echo "" > log/emqx.log.1 + ?SH-PROMPT + + !cp -f ../$PROFILE-ubuntu20.04-$VSN-amd64.zip releases/ + + !./bin/emqx install $VSN + ?Made release permanent: "$VSN" + ?SH-PROMPT + + !./bin/emqx versions |grep permanent + ?(.*)$VSN + ?SH-PROMPT + + !./bin/emqx_ctl cluster status + """??? + Cluster status: #{running_nodes => ['emqx2@127.0.0.1','emqx@127.0.0.1'], + stopped_nodes => []} + """ + ?SH-PROMPT + + !./bin/emqx_ctl plugins list | grep emqx_management + ?Plugin\(emqx_management.*active=true\) + ?SH-PROMPT + +[shell bench] + ???publish complete + ??SH-PROMPT: + !sleep 30 + ?SH-PROMPT + + !curl --user admin:public --silent --show-error http://localhost:8081/api/v4/rules | jq --raw-output ".data[0].metrics[] | select(.node==\"emqx@127.0.0.1\").matched" + ?300 + ?SH-PROMPT + + !curl --user admin:public --silent --show-error http://localhost:8081/api/v4/rules | jq --raw-output ".data[0].actions[0].metrics[] | select(.node==\"emqx@127.0.0.1\").success" + ?300 + ?SH-PROMPT + + !curl http://127.0.0.1:8080/counter + ???{"data":300,"code":0} + ?SH-PROMPT + +[shell emqx2] + !cat log/emqx.log.1 |grep -v 691c29ba |tail -n 100 + -error + ??SH-PROMPT: + + !./bin/emqx stop + ?ok + ?SH-PROMPT: + + !rm -rf $PACKAGE_PATH/emqx2 + ?SH-PROMPT: + +[shell emqx] + !cat log/emqx.log.1 |grep -v 691c29ba |tail -n 100 + -error + ??SH-PROMPT: + + !./bin/emqx stop + ?ok + ?SH-PROMPT: + + !rm -rf $PACKAGE_PATH/emqx + ?SH-PROMPT: + +[shell http_server] + !http_server:stop(). + ?ok + ?> + !halt(3). + ?SH-PROMPT: + +[endloop] + +[cleanup] + !echo ==$$?== + ?==0== diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..c563aa10d748c4bcbcc99c150a2f1a95321a8303 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,27 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{erl, src, hrl}] +indent_style = space +indent_size = 4 + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab + +# Matches the exact files either package.json or .travis.yml +[{.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..4ed73da9a30fd9aef18568d6c0332ffb678da704 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +* text=auto +*.* text eol=lf +*.jpg -text +*.png -text +*.pdf -text diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000000000000000000000000000000000..f28160c5090adb9023fd2bfba77f4b34199f7bfb --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,10 @@ +#### Environment + +- OS: +- Erlang/OTP: +- EMQ: + +#### Description + +*A description of the issue* + diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000000000000000000000000000000000000..9a2e1dc18b3ed4dad495e792f967dca0e23bc931 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,26 @@ +--- +name: Bug Report +about: Create a report to help us improve +title: '' +labels: Support +assignees: h7ml + +--- + + + + +**Environment**: + +- dgiot version (e.g. `dgiot_ctl status`): +- Hardware configuration (e.g. `lscpu`): +- OS (e.g. `cat /etc/os-release`): +- Kernel (e.g. `uname -a`): +- Erlang/OTP version (in case you build emqx from source code): +- Others: + +**What happened and what you expected to happen**: + +**How to reproduce it (as minimally and precisely as possible)**: + +**Anything else we need to know?**: diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000000000000000000000000000000000000..bf5e8f48bf5b84e0d3a7341b4eae83aea1f41cf9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,14 @@ +--- +name: Feature Request +about: Suggest an idea for this project +title: '' +labels: Feature +assignees: h7ml + +--- + + + +**What would you like to be added/modified**: + +**Why is this needed**: diff --git a/.github/ISSUE_TEMPLATE/support-needed.md b/.github/ISSUE_TEMPLATE/support-needed.md new file mode 100644 index 0000000000000000000000000000000000000000..0c03a5968cd6cbcb63817b7212fb7a3f6b7b8b3c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support-needed.md @@ -0,0 +1,10 @@ +--- +name: Support Needed +about: Asking a question about usages, docs or anything you're insterested in +title: '' +labels: Support +assignees: h7ml + +--- + +**Please describe your problem in detail, if necessary, you can upload the log file through the attachment**: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000000000000000000000000000000000..dd0a14dd41ac304104ab227ae320ca395c26ff9b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ + +Fixes + +**If your build fails** due to your commit message not passing the build checks, please review the guidelines here: https://github.com/emqx/emqx/blob/master/CONTRIBUTING.md. + +## PR Checklist +Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked: + +- [ ] Tests for the changes have been added (for bug fixes / features) +- [ ] Docs have been added / updated (for bug fixes / features) +- [ ] In case of non-backward compatible changes, reviewer should check this item as a write-off, and add details in **Backward Compatibility** section + +## Backward Compatibility + +## More information diff --git a/.github/weekly-digest.yml b/.github/weekly-digest.yml new file mode 100644 index 0000000000000000000000000000000000000000..401ea76381288e36e7135ae470ee014f07140eb7 --- /dev/null +++ b/.github/weekly-digest.yml @@ -0,0 +1,7 @@ +# Configuration for weekly-digest - https://github.com/apps/weekly-digest +publishDay: monday +canPublishIssues: true +canPublishPullRequests: true +canPublishContributors: true +canPublishStargazers: true +canPublishCommits: true diff --git a/.github/workflows/.gitlint b/.github/workflows/.gitlint new file mode 100644 index 0000000000000000000000000000000000000000..bf89ba2534b677346279dcca9aab5f5e0bdd334b --- /dev/null +++ b/.github/workflows/.gitlint @@ -0,0 +1,119 @@ +# Edit this file as you like. +# +# All these sections are optional. Each section with the exception of [general] represents +# one rule and each key in it is an option for that specific rule. +# +# Rules and sections can be referenced by their full name or by id. For example +# section "[body-max-line-length]" could also be written as "[B1]". Full section names are +# used in here for clarity. +# +[general] +# Ignore certain rules, this example uses both full name and id +ignore=title-trailing-punctuation, T1, T2, T3, T4, T5, T6, T8, B1, B2, B3, B4, B5, B6, B7, B8 + +# verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this +# verbosity = 2 + +# By default gitlint will ignore merge, revert, fixup and squash commits. +# ignore-merge-commits=true +# ignore-revert-commits=true +# ignore-fixup-commits=true +# ignore-squash-commits=true + +# Ignore any data send to gitlint via stdin +# ignore-stdin=true + +# Fetch additional meta-data from the local repository when manually passing a +# commit message to gitlint via stdin or --commit-msg. Disabled by default. +# staged=true + +# Enable debug mode (prints more output). Disabled by default. +# debug=true + +# Enable community contributed rules +# See http://jorisroovers.github.io/gitlint/contrib_rules for details +# contrib=contrib-title-conventional-commits,CC1 + +# Set the extra-path where gitlint will search for user defined rules +# See http://jorisroovers.github.io/gitlint/user_defined_rules for details +# extra-path=examples/ + +# This is an example of how to configure the "title-max-length" rule and +# set the line-length it enforces to 80 +# [title-max-length] +# line-length=50 + +# Conversely, you can also enforce minimal length of a title with the +# "title-min-length" rule: +# [title-min-length] +# min-length=5 + +# [title-must-not-contain-word] +# Comma-separated list of words that should not occur in the title. Matching is case +# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING" +# will not cause a violation, but "WIP: my title" will. +# words=wip + +[title-match-regex] +# python-style regex that the commit-msg title must match +# Note that the regex can contradict with other rules if not used correctly +# (e.g. title-must-not-contain-word). +regex=^(feat|fix|docs|style|refactor|test|build|ci|revert|chore|perf)(\(.+\))*: .+ + +# [body-max-line-length] +# line-length=72 + +# [body-min-length] +# min-length=5 + +# [body-is-missing] +# Whether to ignore this rule on merge commits (which typically only have a title) +# default = True +# ignore-merge-commits=false + +# [body-changed-file-mention] +# List of files that need to be explicitly mentioned in the body when they are changed +# This is useful for when developers often erroneously edit certain files or git submodules. +# By specifying this rule, developers can only change the file when they explicitly reference +# it in the commit message. +# files=gitlint/rules.py,README.md + +# [body-match-regex] +# python-style regex that the commit-msg body must match. +# E.g. body must end in My-Commit-Tag: foo +# regex=My-Commit-Tag: foo$ + +# [author-valid-email] +# python-style regex that the commit author email address must match. +# For example, use the following regex if you only want to allow email addresses from foo.com +# regex=[^@]+@foo.com + +[ignore-by-title] +# Ignore certain rules for commits of which the title matches a regex +# E.g. Match commit titles that start with "Release" +# regex=^Release(.*) + +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +# ignore=T1,body-min-length + +[ignore-by-body] +# Ignore certain rules for commits of which the body has a line that matches a regex +# E.g. Match bodies that have a line that that contain "release" +# regex=(.*)release(.*) +# +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +# ignore=T1,body-min-length + +# [ignore-body-lines] +# Ignore certain lines in a commit body that match a regex. +# E.g. Ignore all lines that start with 'Co-Authored-By' +# regex=^Co-Authored-By + +# This is a contrib rule - a community contributed rule. These are disabled by default. +# You need to explicitly enable them one-by-one by adding them to the "contrib" option +# under [general] section above. +# [contrib-title-conventional-commits] +# Specify allowed commit types. For details see: https://www.conventionalcommits.org/ +# types = bugfix,user-story,epic diff --git a/.github/workflows/accurics.yaml b/.github/workflows/accurics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1df3e3940a2682883a1c7ba01d44a411d998c38a --- /dev/null +++ b/.github/workflows/accurics.yaml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + workflow_dispatch: +jobs: + accurics-scan: + runs-on: ubuntu-latest + name: accurics-scan + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Accurics Scan + id: accurics-scan + uses: docker://accurics/terrascan-action:latest + with: + only_warn: true + verbose: true + webhook_url: https://app.accurics.com/v1/api/terrascan + webhook_token: a20de3ab-f00e-4e1a-a37f-dbceafe4150e \ No newline at end of file diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bf85578c59ca2c798f939a89ee18ba539ed751ac --- /dev/null +++ b/.github/workflows/build_slim_packages.yaml @@ -0,0 +1,132 @@ +name: Build slim packages + +on: + push: + tags: + - v* + - e* + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-20.04 + + strategy: + matrix: + erl_otp: + - erl23.2.7.2-emqx-2 + os: + - ubuntu20.04 + - centos7 + + container: emqx/build-env:${{ matrix.erl_otp }}-${{ matrix.os }} + + steps: + - uses: actions/checkout@v1 + - name: prepare + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials + git config --global credential.helper store + echo "${{ secrets.CI_GIT_TOKEN }}" >> ./scripts/git-token + echo "EMQX_NAME=emqx-ee" >> $GITHUB_ENV + else + echo "EMQX_NAME=emqx" >> $GITHUB_ENV + fi + - name: build zip packages + run: make ${EMQX_NAME}-zip + - name: build deb/rpm packages + run: make ${EMQX_NAME}-pkg + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: rebar3.crashdump + path: ./rebar3.crashdump + - name: pakcages test + run: | + export CODE_PATH=$GITHUB_WORKSPACE + .ci/build_packages/tests.sh + - uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.os }} + path: _packages/**/*.zip + + mac: + runs-on: macos-10.15 + + strategy: + matrix: + erl_otp: + - 23.2.7.2-emqx-2 + + steps: + - uses: actions/checkout@v1 + - name: prepare + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials + git config --global credential.helper store + echo "${{ secrets.CI_GIT_TOKEN }}" >> ./scripts/git-token + echo "EMQX_NAME=emqx-ee" >> $GITHUB_ENV + else + echo "EMQX_NAME=emqx" >> $GITHUB_ENV + fi + - name: prepare + run: | + brew update + brew install curl zip unzip gnu-sed kerl unixodbc freetds + echo "/usr/local/bin" >> $GITHUB_PATH + git config --global credential.helper store + - uses: actions/cache@v2 + id: cache + with: + path: ~/.kerl + key: erl${{ matrix.erl_otp }}-macos10.15 + - name: build erlang + if: steps.cache.outputs.cache-hit != 'true' + timeout-minutes: 60 + env: + KERL_BUILD_BACKEND: git + OTP_GITHUB_URL: https://github.com/emqx/otp + run: | + kerl update releases + kerl build ${{ matrix.erl_otp }} + kerl install ${{ matrix.erl_otp }} $HOME/.kerl/${{ matrix.erl_otp }} + - name: build + run: | + . $HOME/.kerl/${{ matrix.erl_otp }}/activate + make ensure-rebar3 + sudo cp rebar3 /usr/local/bin/rebar3 + make ${EMQX_NAME}-zip + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: rebar3.crashdump + path: ./rebar3.crashdump + - name: test + run: | + pkg_name=$(basename _packages/${EMQX_NAME}/emqx-*.zip) + unzip -q _packages/${EMQX_NAME}/$pkg_name + gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins + ./emqx/bin/emqx start || cat emqx/log/erlang.log.1 + ready='no' + for i in {1..10}; do + if curl -fs 127.0.0.1:18083 > /dev/null; then + ready='yes' + break + fi + sleep 1 + done + if [ "$ready" != "yes" ]; then + echo "Timed out waiting for emqx to be ready" + cat emqx/log/erlang.log.1 + exit 1 + fi + ./emqx/bin/emqx_ctl status + ./emqx/bin/emqx stop + rm -rf emqx + - uses: actions/upload-artifact@v2 + with: + name: macos + path: _packages/**/*.zip diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000000000000000000000000000000000..7cbb0e6d42a90ff10867e56eb58e4aab9c84c332 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,17 @@ +name: Continuos Integration with Github + +on: + push: + tags: + - 'v*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Publish to Docker Repository + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: ispeakcode/docker-githubaction + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/gitee-repos-mirror.yml b/.github/workflows/gitee-repos-mirror.yml new file mode 100644 index 0000000000000000000000000000000000000000..f9b470ddad2723b5b28dc005d3f03b4dc291b276 --- /dev/null +++ b/.github/workflows/gitee-repos-mirror.yml @@ -0,0 +1,60 @@ +name: Gitee repos mirror periodic job + +on: + push: + watch: + types: started + schedule: + - cron: "0 23 * * *" + +jobs: + dgiot: + name: dgiot + runs-on: ubuntu-latest + steps: + - name: dgiot + uses: Yikun/hub-mirror-action@v1.0 + with: + src: github/dgiot + dst: gitee/dgiiot + dst_key: ${{ secrets.PRIVATE_KEY }} + dst_token: ${{ secrets.TOKEN }} + account_type: org + timeout: '1h' + debug: true + force_update: true + static_list: "dgiot" + dgiot-org: + name: dgiot-org + runs-on: ubuntu-latest + steps: + - name: dgiot + uses: Yikun/hub-mirror-action@v1.0 + with: + src: github/dgiot + dst: gitee/dgiiot + dst_key: ${{ secrets.PRIVATE_KEY }} + dst_token: ${{ secrets.TOKEN }} + account_type: org + timeout: '1h' + debug: true + force_update: true + black_list: "issue-generator,dgiot-dashboard" + needs: fastdgiot + fastdgiot: + name: fastdgiot + runs-on: ubuntu-latest + steps: + - name: fastdgiot + uses: Yikun/hub-mirror-action@v1.0 + with: + src: github/dgiot + dst: gitee/fastdgiot + dst_key: ${{ secrets.PRIVATE_KEY }} + dst_token: ${{ secrets.TOKEN }} + account_type: org + timeout: '1h' + debug: true + force_update: true + static_list: "dgiot" # 只同步这个项目 https://github.com/Yikun/hub-mirror-action#%E9%BB%91%E7%99%BD%E5%90%8D%E5%8D%95 + needs: dgiot diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 0000000000000000000000000000000000000000..0db4debc47feee9cafbb1983967726a7d78f7daa --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,23 @@ +# This workflow will triage pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler + +name: Labeler +on: [pull_request] + +jobs: + label: + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - uses: rhysd/changelog-from-release/action@v2 + with: + file: CHANGELOG.md + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000000000000000000000000000000000..7e2afdf219913163a40605731eaf230897fa63f2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ + +# https://github.com/actions/create-release +name: Create Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@master + + - name: Create Release + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..bc1e402a1f0086f471a0c7e759aa5fde522a02e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,89 @@ +.eunit +test-data/ +deps +!deps/.placeholder +_build/ +www/ +*.o +*.beam +*.plt +*.iml +*.iws +erl_crash.dump +ebin +!ebin/.placeholder +.concrete/DEV_MODE +.rebar +test/ebin/*.beam +.exrc +plugins/*/ebin +*.swp +*.so +.erlang.mk/ +cover/ +eunit.coverdata +test/ct.cover.spec +ct.coverdata +.idea/ +_build +.rebar3 +rebar3.crashdump +.DS_Store +etc/gen.emqx.conf +compile_commands.json +cuttlefish +xrefr +*.coverdata +etc/emqx.conf.rendered +Mnesia.*/ +*.DS_Store +_checkouts +./rebar.config +./rebar.config.erl +rebar.config.rendered +/rebar3 +rebar.lock +.stamp +tmp/ +_packages +elvis +emqx_dialyzer_*_plt +*/emqx_dashboard/priv/www +dist.zip +scripts/git-token +etc/*.seg +_upgrade_base/ +data/ +ci.sh +*.ipr +node_modules/ +apps/emqx_* +apps/dgiot_parse/etc/dgiot_parse.conf +apps/dgiot_parse/etc/dgiot_parse_temp.conf +apps/dgiot_jieshun/ +apps/dgiot_mingcheng/ +apps/dgiot_xinchuangwei/ +apps/dgiot_hikvision/ +apps/dgiot_meter_not_open_source/ +apps/dgiot_esports/ +apps/dgiot_sinmahe/ +apps/dgiot_yinhu/ +apps/dgiot_dahua/ +apps/dgiot_kingdee/ +apps/dgiot_jetlinks/ +apps/dgiot_http/etc/dgiot_http.conf +apps/emqx_* +node_modules/ +package-lock.json +erlang_ls.config +.els_cache/ +# VSCode files +.vs/ +.vscode/ +# Emacs Backup files +*~ +# Emacs temporary files +.#* +# For direnv +.envrc +*.log diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 81d39d34d44e1bdc397a0764a864584229b49053..0000000000000000000000000000000000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/.idea/dgiot_server.iml b/.idea/dgiot_server.iml deleted file mode 100644 index daa9e52f17a45c16212baa37bbf87fce94ea8d15..0000000000000000000000000000000000000000 --- a/.idea/dgiot_server.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index a86d5be097261d5bec5394395c8f4c0da21adac5..0000000000000000000000000000000000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 0b6ffa81a449a2507647784baee804905741b784..0000000000000000000000000000000000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index ef33f32a179cda396fe9a432f9384c74edb85c28..0000000000000000000000000000000000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000000000000000000000000000000000000..0b6392b95724afa887cc8981c7431dd3dc2faad2 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +erlang 23.2.7.2-emqx-3 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..d324ba087c08e023beda03702b9cf6f1c8c28ffe --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,183 @@ +# [4.4.0](https://github.com/dgiot/dgiot/compare/v4.3.9...v) (2021-11-23) + + +### Features + +* add dgiot_image ([c52dd70](https://github.com/dgiot/dgiot/commit/c52dd7007227963a7b1f455a0e22959fe6d2e00d)) +* evidence_topo ([9e5a5f6](https://github.com/dgiot/dgiot/commit/9e5a5f6f147775ab470dca016027b733554e5a91)) +* post_evidence ([3f927bc](https://github.com/dgiot/dgiot/commit/3f927bcc06093fffe28b7749440ad95dd00c683d)) +* post_evidence ([8d109b0](https://github.com/dgiot/dgiot/commit/8d109b0bfd5cefadc8c0dff787690a29c9417980)) + + + +## [4.3.9](https://github.com/dgiot/dgiot/compare/v4.3.8...v4.3.9) (2021-11-19) + + +### Features + +* evidence_category ([d495519](https://github.com/dgiot/dgiot/commit/d495519c4d07b0e008e97319e04830cd40afe58e)) +* refresh_session ([c56a594](https://github.com/dgiot/dgiot/commit/c56a5940e3a954a694d52c0edc0ffd2075bb1736)) +* sync_dict,view ([170e2d1](https://github.com/dgiot/dgiot/commit/170e2d1f93b43506c70d7672a1ce809f8f0ff77b)) + + + +## [4.3.8](https://github.com/dgiot/dgiot/compare/v4.3.7...v4.3.8) (2021-11-12) + + +### Features + +* dgiot_install 68 ([63abd74](https://github.com/dgiot/dgiot/commit/63abd74fffdd592cdb56b2d09c26ff4af43ceaf1)) +* do_report ([974baad](https://github.com/dgiot/dgiot/commit/974baadcda32ecccd1fe03505347b910c649e5ea)) + + + +## [4.3.7](https://github.com/dgiot/dgiot/compare/v4.3.6...v4.3.7) (2021-11-10) + + +### Features + +* Modify swagger ([d4175a8](https://github.com/dgiot/dgiot/commit/d4175a8138cd778b29b8a2d8869c201eb1a9d383)) +* reporttemplate ([3cc8a70](https://github.com/dgiot/dgiot/commit/3cc8a705d2b7ab9e27195f94a5554b29502d2dd6)) + + + +## [4.3.6](https://github.com/dgiot/dgiot/compare/v4.3.5...v4.3.6) (2021-11-04) + + +### Bug Fixes + +* get_env ([58e2d52](https://github.com/dgiot/dgiot/commit/58e2d52212b9f859f4195023e432837d74545fc0)) +* install centos 7.9 ([16028f4](https://github.com/dgiot/dgiot/commit/16028f4c201920cf7c62a21176a9a492fc97f6aa)) + + +### Features + +* add post testpaper ([b7ad572](https://github.com/dgiot/dgiot/commit/b7ad572265deafa0c479817dfb46c9967b03917e)) +* centos 7.9 ([a7e56a6](https://github.com/dgiot/dgiot/commit/a7e56a630e22db7a1e8513c96ec58f3127a6cd7c)) +* Configuration modification Label ([b71b0c2](https://github.com/dgiot/dgiot/commit/b71b0c2094f5e184efbe86f6eeecea594676a7be)) +* device_card ([6c54a07](https://github.com/dgiot/dgiot/commit/6c54a07013fb7b9b92e5ddaf498471488b1341a7)) +* go-fastdfs Api ([c4ad4e4](https://github.com/dgiot/dgiot/commit/c4ad4e4ed5be37b0b9c3abb7211746c38d26cf96)) +* go-fastdfs Api ([3160613](https://github.com/dgiot/dgiot/commit/316061335e7c96bcea36d6d55da6cbc3d76931e9)) +* modbus_rtu:format_value() ([af12dda](https://github.com/dgiot/dgiot/commit/af12dda71f09fe506288627bd430768d8b4bbcdc)) +* rm esports ([c33dedd](https://github.com/dgiot/dgiot/commit/c33dedd1340ad0b3fbd00f4a74a6d62678a4ef76)) + + + +## [4.3.5](https://github.com/dgiot/dgiot/compare/v4.3.4...v4.3.5) (2021-10-15) + + +### Bug Fixes + +* add device log ([f3b173c](https://github.com/dgiot/dgiot/commit/f3b173c3f146e1ddf21038b5026dfd08ae93c95f)) +* channel_log ([1e37058](https://github.com/dgiot/dgiot/commit/1e3705876eb905cab215085e7341e050ce822170)) +* dtl645 parse_frame ([13348c8](https://github.com/dgiot/dgiot/commit/13348c823d4c31884e8d76160f5b93aa6e0b2391)) +* fix mqtt trace bug ([1a53ebe](https://github.com/dgiot/dgiot/commit/1a53ebec4ecf68ad2e19c14d43ed47fbcbed1754)) +* post trace failed ([544eed5](https://github.com/dgiot/dgiot/commit/544eed54b1798fe799f885f5af99a06582fa115b)) +* publish topic error ([b3ab5fc](https://github.com/dgiot/dgiot/commit/b3ab5fcc4ac52467a192a3ea685d1a155b314445)) +* task_worker bug ([0396163](https://github.com/dgiot/dgiot/commit/039616312126d24e36b03cf339e0e6ffb6f3aa13)) +* tcp save device log ([ef4a240](https://github.com/dgiot/dgiot/commit/ef4a24066fe31ad823a79a9546d991a4ca043a3c)) + + +### Features + +* add task metircs ([79cfd2d](https://github.com/dgiot/dgiot/commit/79cfd2dc45e8a396dff7351eaf40ab5e07be83c5)) +* add tcp channel device log ([c74b246](https://github.com/dgiot/dgiot/commit/c74b246443244f981e847bcb1f559f7ec4d2d375)) +* add tcp connect info ([39a1cc9](https://github.com/dgiot/dgiot/commit/39a1cc93ecf25796eabca67aac1789258dc58037)) +* add tcp metircs ([f8e19b1](https://github.com/dgiot/dgiot/commit/f8e19b1b241200b5d1324d689f4e2d9536e74a4d)) +* add tcp save log ([868c8d0](https://github.com/dgiot/dgiot/commit/868c8d09e732ca3872ffe4ef5149263c2d5e97ae)) +* add tcp transparent ([b1f091c](https://github.com/dgiot/dgiot/commit/b1f091cba9fa143fcc8040a6fa8848ac89412e96)) +* add tdengie metrics ([c38b046](https://github.com/dgiot/dgiot/commit/c38b046f1939bf6d59a106a62b2b1f3c86a89127)) +* add trace log, Modify meter channel ([d4b9fd7](https://github.com/dgiot/dgiot/commit/d4b9fd758e2ca2643bdf5c560aa32ff441fac22f)) +* add transparent log ([b432ce6](https://github.com/dgiot/dgiot/commit/b432ce6c13e3b1664685d74a6e5c08b73be987de)) +* trace ([1eadb3a](https://github.com/dgiot/dgiot/commit/1eadb3acd12b3b6c7c818771999f2b5c3fc8b9a7)) + + +### Performance Improvements + +* add dgiot topo readme" ([e6623c1](https://github.com/dgiot/dgiot/commit/e6623c1b69b56a62635dd886a5374ad29171e6fd)) + + + +## [4.3.4](https://github.com/dgiot/dgiot/compare/v4.3.3...v4.3.4) (2021-09-24) + + +### Bug Fixes + +* channel log,install.sh ([9fcc72c](https://github.com/dgiot/dgiot/commit/9fcc72ccd7dc4f2b67b744bf4ccb393142022bc0)) +* dgiot_install.sh ([84564e8](https://github.com/dgiot/dgiot/commit/84564e85abb245c68249e288510357743c0e96eb)) +* install.sh ([44fd008](https://github.com/dgiot/dgiot/commit/44fd008e3f60169cf0f67ea873f7a899d29eba01)) +* Repair channel loading failed ([1898ebe](https://github.com/dgiot/dgiot/commit/1898ebea684ca1c9cebf4bf00742ea11689145ee)) + + +### Features + +* add dgiot wechat ([dd6d76d](https://github.com/dgiot/dgiot/commit/dd6d76d921fcaf4722d3985ea1c69c0d9f5a23ea)) +* add mqtt trace ([6100f50](https://github.com/dgiot/dgiot/commit/6100f500ed25126034270a9bd4afdc838f9d687e)) +* add tcp socket register_channel fucntion ([28a8676](https://github.com/dgiot/dgiot/commit/28a8676552ae4226aa6d3fc1fd31812396527d1f)) +* apps/dgiot_gb26875:Urban fire remote monitoring system gb26875 protocol analysis channel ([c38b9b9](https://github.com/dgiot/dgiot/commit/c38b9b9ca730c97cb7d0bbccbf3d2cc1297f606f)) +* Fix script invalidation problem ([f68a3f0](https://github.com/dgiot/dgiot/commit/f68a3f0c85edcff49c10b209d854a2a2cfe75c73)) + + + +## [4.3.3](https://github.com/dgiot/dgiot/compare/v4.3.2...v4.3.3) (2021-09-18) + + +### Bug Fixes + +* shouyinchengchannel cType ([442bee6](https://github.com/dgiot/dgiot/commit/442bee6c8a104ea9e5c588de549899436a0c99bd)) +* test ([cf09d38](https://github.com/dgiot/dgiot/commit/cf09d384cbae75e22a7332145bf6173c9de6d397)) +* test change log ([1d03322](https://github.com/dgiot/dgiot/commit/1d033226a84d78d1d250b22c05907cfb5444c228)) + + +### Features + +* ... ([d285393](https://github.com/dgiot/dgiot/commit/d2853938f1a13c45ecebb3a38142e2207ea802cf)) + + + +## [4.3.2](https://github.com/dgiot/dgiot/compare/v4.3.1...v4.3.2) (2021-09-13) + + +### Bug Fixes + +* addtd files ([c91a199](https://github.com/dgiot/dgiot/commit/c91a1993cd06777eb9304a07068ef1000f20aa00)) +* device_card ([50914b4](https://github.com/dgiot/dgiot/commit/50914b4bbefb9fcdf5049d5c4a36cac21819786f)) +* devicelog ([e747cee](https://github.com/dgiot/dgiot/commit/e747cee225e37f1050026781fe89418b19dadc7e)) +* igore rebar.config ([5e61214](https://github.com/dgiot/dgiot/commit/5e61214789aa382f6a8be126830b14c3c834a1cc)) +* parse.conf ([488c12e](https://github.com/dgiot/dgiot/commit/488c12e793fa2b94acfa01d0585072ca3a47d275)) + + +### Features + +* add acl to log ([2533081](https://github.com/dgiot/dgiot/commit/2533081a08a64203d1a3b17090bd3dc53497d8b2)) +* add dgiot log ([59b9906](https://github.com/dgiot/dgiot/commit/59b9906bd10ebb42c0439967c3989d1cdd6b9d29)) +* ssl ([f673266](https://github.com/dgiot/dgiot/commit/f6732665fd737a34147d06998f5328e605933906)) +* xiufubug ([f4c9d75](https://github.com/dgiot/dgiot/commit/f4c9d75653f789a07e700574deadaddd645b6f36)) + + + +## [4.3.1](https://github.com/dgiot/dgiot/compare/v4.3.0...v4.3.1) (2021-08-30) + + +### Bug Fixes + +* get_actions ([cb81e42](https://github.com/dgiot/dgiot/commit/cb81e42a6a94e18fe5e2e74a243240a4a23fd0bc)) +* get_channel params ([be0409b](https://github.com/dgiot/dgiot/commit/be0409b11b8c27e55d56f1a70a38b2a452e550e9)) +* get_resources ([2e218ed](https://github.com/dgiot/dgiot/commit/2e218edd97efe5621bd0463b4a4c7652535686de)) + + +### Features + +* 迁移脚本 && 字段修å值重复 ([1d69ba7](https://github.com/dgiot/dgiot/commit/1d69ba76facb9a4caab218c240eef750258bc4f1)) +* api get_table ([2a3606d](https://github.com/dgiot/dgiot/commit/2a3606dd8ded698c3003e7cef0a839f1807b543a)) +* get_maintenanceid ([195e43c](https://github.com/dgiot/dgiot/commit/195e43ccf2482af799d80362b88a23c581f2eaed)) +* get_provider ([ebb5c57](https://github.com/dgiot/dgiot/commit/ebb5c571c4a20c916fcafb091b90aa546d7954d4)) +* scripts ([810bfe5](https://github.com/dgiot/dgiot/commit/810bfe5fce8f39a536f56d1952649973af810012)) +* swagger description ([3bdb162](https://github.com/dgiot/dgiot/commit/3bdb162d0a4057a78a1e45e47ba04dbb91473ae2)) + + + +# 4.3.0 (2021-05-27) + + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..4a3070aff1c152f7db98757705ac7cd786fa8d00 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,98 @@ +# Contributing + +You are welcome to submit any bugs, issues and feature requests on this repository. + + +## Commit Message Guidelines + +We have very precise rules over how our git commit messages can be formatted. This leads to **more readable messages** that are easy to follow when looking through the **project history**. + +### Commit Message Format + +Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**: + +``` +(): + + + +