From f83db4a345ab5406a8a2f2b074fd9161b2193dd6 Mon Sep 17 00:00:00 2001 From: "U-JOHNLIU\\jonhl" Date: Tue, 18 May 2021 14:54:48 +0800 Subject: [PATCH] add linux_4.3.1 --- .ci/build_packages/Dockerfile | 14 + .ci/build_packages/tests.sh | 161 + .ci/docker-compose-file/.env | 8 + .ci/docker-compose-file/conf.cluster.env | 7 + .ci/docker-compose-file/conf.env | 13 + .../docker-compose-emqx-cluster.yaml | 85 + .../docker-compose-ldap-tcp.yaml | 16 + .../docker-compose-mongo-tcp.yaml | 14 + .../docker-compose-mongo-tls.yaml | 18 + .../docker-compose-mysql-tcp.yaml | 20 + .../docker-compose-mysql-tls.yaml | 45 + .../docker-compose-pgsql-tcp.yaml | 15 + .../docker-compose-pgsql-tls.yaml | 32 + .../docker-compose-python.yaml | 15 + .../docker-compose-redis-cluster-tcp.yaml | 11 + .../docker-compose-redis-cluster-tls.yaml | 12 + .../docker-compose-redis-sentinel-tcp.yaml | 11 + .../docker-compose-redis-sentinel-tls.yaml | 12 + .../docker-compose-redis-single-tcp.yaml | 13 + .../docker-compose-redis-single-tls.yaml | 19 + .ci/docker-compose-file/docker-compose.yaml | 35 + .ci/docker-compose-file/haproxy/haproxy.cfg | 109 + .ci/docker-compose-file/openldap/Dockerfile | 26 + .ci/docker-compose-file/openldap/slapd.conf | 16 + .ci/docker-compose-file/pgsql/Dockerfile | 12 + .ci/docker-compose-file/pgsql/pg_hba.conf | 9 + .ci/docker-compose-file/python/pytest.sh | 24 + .ci/docker-compose-file/redis/redis-tls.conf | 11 + .ci/docker-compose-file/redis/redis.conf | 5 + .ci/docker-compose-file/redis/redis.sh | 125 + .ci/fvt_tests/.env | 1 + .ci/fvt_tests/http_server/README.md | 30 + .ci/fvt_tests/http_server/rebar.config | 10 + .../http_server/src/http_server.app.src | 17 + .ci/fvt_tests/http_server/src/http_server.erl | 50 + .ci/fvt_tests/relup.lux | 149 + .editorconfig | 27 + .gitattributes | 5 + .github/ISSUE_TEMPLATE.md | 10 + .github/ISSUE_TEMPLATE/bug-report.md | 26 + .github/ISSUE_TEMPLATE/feature-request.md | 14 + .github/ISSUE_TEMPLATE/support-needed.md | 10 + .github/PULL_REQUEST_TEMPLATE.md | 15 + .github/weekly-digest.yml | 7 + .github/workflows/.gitlint | 119 + .github/workflows/apps_version_check.yaml | 12 + .github/workflows/build_packages.yaml | 480 +++ .github/workflows/build_slim_packages.yaml | 116 + .github/workflows/check_deps_integrity.yaml | 13 + .github/workflows/elvis_lint.yaml | 16 + .github/workflows/git_sync.yaml | 42 + .github/workflows/gitee-repos-mirror.yml | 28 - .github/workflows/run_cts_tests.yaml | 406 +++ .github/workflows/run_fvt_tests.yaml | 273 ++ .github/workflows/run_gitlint.yaml | 44 + .github/workflows/run_test_cases.yaml | 154 + .github/workflows/shellcheck.yaml | 18 + .gitignore | 55 +- .tool-versions | 1 + CONTRIBUTING.md | 82 + Makefile | 245 +- README-CN.md | 151 + README-JP.md | 131 + README-RU.md | 141 + README.md | 32 +- Windows.md | 127 + apps/.gitkeep | 0 apps/emqx_bridge_mqtt/.gitignore | 21 + apps/emqx_bridge_mqtt/README.md | 265 ++ apps/emqx_bridge_mqtt/docs/guide.rst | 286 ++ apps/emqx_bridge_mqtt/docs/images/bridge.png | Bin 0 -> 147486 bytes .../etc/emqx_bridge_mqtt.conf | 174 ++ .../include/emqx_bridge_mqtt.hrl | 18 + .../priv/emqx_bridge_mqtt.schema | 244 ++ apps/emqx_bridge_mqtt/rebar.config | 19 + .../src/emqx_bridge_connect.erl | 74 + .../src/emqx_bridge_mqtt.app.src | 14 + .../src/emqx_bridge_mqtt.appup.src | 10 + .../emqx_bridge_mqtt/src/emqx_bridge_mqtt.erl | 204 ++ .../src/emqx_bridge_mqtt_actions.erl | 578 ++++ .../src/emqx_bridge_mqtt_app.erl | 33 + .../src/emqx_bridge_mqtt_cli.erl | 92 + .../src/emqx_bridge_mqtt_sup.erl | 84 + apps/emqx_bridge_mqtt/src/emqx_bridge_msg.erl | 99 + apps/emqx_bridge_mqtt/src/emqx_bridge_rpc.erl | 100 + .../src/emqx_bridge_worker.erl | 641 ++++ .../test/emqx_bridge_mqtt_tests.erl | 47 + .../test/emqx_bridge_rpc_tests.erl | 42 + .../test/emqx_bridge_stub_conn.erl | 41 + .../test/emqx_bridge_worker_SUITE.erl | 343 +++ .../test/emqx_bridge_worker_tests.erl | 134 + apps/emqx_exhook/.gitignore | 29 + apps/emqx_exhook/README.md | 39 + apps/emqx_exhook/docs/design-cn.md | 116 + apps/emqx_exhook/etc/emqx_exhook.conf | 15 + apps/emqx_exhook/include/emqx_exhook.hrl | 44 + apps/emqx_exhook/priv/emqx_exhook.schema | 38 + apps/emqx_exhook/priv/protos/exhook.proto | 407 +++ apps/emqx_exhook/rebar.config | 49 + apps/emqx_exhook/src/emqx_exhook.app.src | 12 + apps/emqx_exhook/src/emqx_exhook.erl | 136 + apps/emqx_exhook/src/emqx_exhook_app.erl | 94 + apps/emqx_exhook/src/emqx_exhook_cli.erl | 81 + apps/emqx_exhook/src/emqx_exhook_handler.erl | 321 ++ apps/emqx_exhook/src/emqx_exhook_server.erl | 320 ++ apps/emqx_exhook/src/emqx_exhook_sup.erl | 59 + apps/emqx_exhook/test/emqx_exhook_SUITE.erl | 96 + .../emqx_exhook/test/emqx_exhook_demo_svr.erl | 339 +++ .../test/props/prop_exhook_hooks.erl | 531 ++++ apps/emqx_exproto/.gitignore | 48 + apps/emqx_exproto/README.md | 24 + apps/emqx_exproto/docs/design-cn.md | 127 + .../emqx_exproto/docs/images/exproto-arch.jpg | Bin 0 -> 72633 bytes .../docs/images/exproto-grpc-arch.jpg | Bin 0 -> 97464 bytes apps/emqx_exproto/etc/emqx_exproto.conf | 252 ++ apps/emqx_exproto/include/emqx_exproto.hrl | 37 + apps/emqx_exproto/priv/emqx_exproto.schema | 364 +++ apps/emqx_exproto/priv/protos/exproto.proto | 259 ++ apps/emqx_exproto/rebar.config | 52 + apps/emqx_exproto/src/emqx_exproto.app.src | 12 + apps/emqx_exproto/src/emqx_exproto.erl | 187 ++ apps/emqx_exproto/src/emqx_exproto_app.erl | 37 + .../emqx_exproto/src/emqx_exproto_channel.erl | 596 ++++ apps/emqx_exproto/src/emqx_exproto_conn.erl | 696 +++++ apps/emqx_exproto/src/emqx_exproto_gcli.erl | 131 + apps/emqx_exproto/src/emqx_exproto_gsvr.erl | 154 + apps/emqx_exproto/src/emqx_exproto_sup.erl | 83 + apps/emqx_exproto/test/emqx_exproto_SUITE.erl | 451 +++ .../test/emqx_exproto_echo_svr.erl | 278 ++ apps/emqx_lua_hook/.gitignore | 19 + apps/emqx_lua_hook/README.md | 338 +++ apps/emqx_lua_hook/etc/emqx_lua_hook.conf | 4 + apps/emqx_lua_hook/examples.lua | 71 + apps/emqx_lua_hook/include/emqx_lua_hook.hrl | 18 + apps/emqx_lua_hook/priv/emqx_lua_hook.schema | 1 + apps/emqx_lua_hook/rebar.config | 21 + apps/emqx_lua_hook/src/emqx_lua_hook.app.src | 14 + apps/emqx_lua_hook/src/emqx_lua_hook.erl | 199 ++ apps/emqx_lua_hook/src/emqx_lua_hook_app.erl | 40 + apps/emqx_lua_hook/src/emqx_lua_hook_cli.erl | 88 + apps/emqx_lua_hook/src/emqx_lua_hook_sup.erl | 35 + apps/emqx_lua_hook/src/emqx_lua_script.erl | 342 +++ .../test/emqx_lua_hook_SUITE.erl | 693 +++++ apps/emqx_management/.gitignore | 28 + apps/emqx_management/README.md | 9 + apps/emqx_management/etc/emqx_management.conf | 53 + apps/emqx_management/include/emqx_mgmt.hrl | 35 + .../priv/emqx_management.schema | 239 ++ apps/emqx_management/rebar.config | 17 + .../src/emqx_management.app.src | 14 + .../src/emqx_management.appup.src | 12 + apps/emqx_management/src/emqx_mgmt.erl | 574 ++++ apps/emqx_management/src/emqx_mgmt_api.erl | 328 ++ .../emqx_management/src/emqx_mgmt_api_acl.erl | 47 + .../src/emqx_mgmt_api_alarms.erl | 137 + .../src/emqx_mgmt_api_apps.erl | 103 + .../src/emqx_mgmt_api_banned.erl | 166 + .../src/emqx_mgmt_api_brokers.erl | 47 + .../src/emqx_mgmt_api_clients.erl | 436 +++ .../src/emqx_mgmt_api_data.erl | 170 ++ .../src/emqx_mgmt_api_listeners.erl | 76 + .../src/emqx_mgmt_api_metrics.erl | 42 + .../src/emqx_mgmt_api_nodes.erl | 46 + .../src/emqx_mgmt_api_plugins.erl | 115 + .../src/emqx_mgmt_api_pubsub.erl | 247 ++ .../src/emqx_mgmt_api_routes.erl | 47 + .../src/emqx_mgmt_api_stats.erl | 45 + .../src/emqx_mgmt_api_subscriptions.erl | 152 + apps/emqx_management/src/emqx_mgmt_app.erl | 35 + apps/emqx_management/src/emqx_mgmt_auth.erl | 210 ++ apps/emqx_management/src/emqx_mgmt_cli.erl | 721 +++++ .../src/emqx_mgmt_data_backup.erl | 738 +++++ apps/emqx_management/src/emqx_mgmt_http.erl | 134 + apps/emqx_management/src/emqx_mgmt_sup.erl | 30 + apps/emqx_management/src/emqx_mgmt_util.erl | 79 + .../test/emqx_auth_mnesia_migration_SUITE.erl | 175 ++ .../make_data.sh | 134 + .../v4.0.11-no-auth.json | 23 + .../v4.0.11.json | 28 + .../v4.0.13.json | 37 + .../v4.1.5.json | 58 + .../v4.2.10-no-auth.json | 29 + .../v4.2.10.json | 53 + .../v4.2.11.json | 58 + ...x_bridge_mqtt_data_export_import_SUITE.erl | 184 ++ .../409.json | 68 + .../415.json | 70 + .../420.json | 70 + .../430.json | 76 + .../ee4010.json | 68 + .../ee410.json | 70 + .../ee411.json | 70 + .../ee420.json | 119 + .../ee425.json | 123 + .../ee430.json | 123 + apps/emqx_management/test/emqx_mgmt_SUITE.erl | 367 +++ .../test/emqx_mgmt_api_SUITE.erl | 602 ++++ .../emqx_webhook_data_export_import_SUITE.erl | 194 ++ .../409.json | 43 + .../415.json | 42 + .../422.json | 43 + .../423.json | 44 + .../425.json | 47 + .../430.json | 52 + .../ee4010.json | 43 + .../ee410.json | 43 + .../ee411.json | 43 + .../ee420.json | 92 + .../ee425.json | 102 + .../ee430.json | 98 + .../test/etc/emqx_management.conf | 35 + .../test/etc/emqx_reloader.conf | 24 + apps/emqx_management/test/rfc6455_client.erl | 252 ++ apps/emqx_management/test/test_utils.erl | 19 + .../src/emqx_plugin_libs.app.src | 7 + .../emqx_plugin_libs/src/emqx_plugin_libs.erl | 18 + .../src/emqx_plugin_libs_ssl.erl | 110 + .../test/emqx_plugin_libs_ssl_tests.erl | 78 + apps/emqx_prometheus/.gitignore | 24 + apps/emqx_prometheus/README.md | 283 ++ apps/emqx_prometheus/TODO | 2 + apps/emqx_prometheus/etc/emqx_prometheus.conf | 13 + .../emqx_prometheus/grafana_template/EMQ.json | 2102 +++++++++++++ .../grafana_template/EMQ_Dashboard.json | 633 ++++ .../grafana_template/ErlangVM.json | 1474 +++++++++ .../include/emqx_prometheus.hrl | 0 .../priv/emqx_prometheus.schema | 20 + apps/emqx_prometheus/rebar.config | 18 + .../src/emqx_prometheus.app.src | 14 + apps/emqx_prometheus/src/emqx_prometheus.erl | 612 ++++ .../src/emqx_prometheus_app.erl | 37 + .../src/emqx_prometheus_sup.erl | 36 + .../test/emqx_prometheus_SUITE.erl | 23 + apps/emqx_psk_file/.gitignore | 16 + apps/emqx_psk_file/README.md | 2 + apps/emqx_psk_file/etc/emqx_psk_file.conf | 2 + apps/emqx_psk_file/etc/psk.txt | 2 + apps/emqx_psk_file/priv/emqx_psk_file.schema | 10 + apps/emqx_psk_file/rebar.config | 16 + apps/emqx_psk_file/src/emqx_psk_file.app.src | 14 + apps/emqx_psk_file/src/emqx_psk_file.erl | 82 + apps/emqx_psk_file/src/emqx_psk_file_app.erl | 33 + apps/emqx_psk_file/src/emqx_psk_file_sup.erl | 32 + .../test/emqx_psk_file_SUITE.erl | 24 + apps/emqx_recon/.gitignore | 31 + apps/emqx_recon/README.md | 61 + apps/emqx_recon/etc/emqx_recon.conf | 4 + apps/emqx_recon/priv/emqx_recon.schema | 9 + apps/emqx_recon/rebar.config | 18 + apps/emqx_recon/src/emqx_recon.app.src | 14 + apps/emqx_recon/src/emqx_recon.erl | 41 + apps/emqx_recon/src/emqx_recon_cli.erl | 72 + apps/emqx_recon/test/emqx_recon_SUITE.erl | 114 + apps/emqx_retainer/.gitignore | 26 + apps/emqx_retainer/README.md | 59 + apps/emqx_retainer/TODO | 1 + apps/emqx_retainer/etc/emqx_retainer.conf | 41 + apps/emqx_retainer/include/emqx_retainer.hrl | 20 + apps/emqx_retainer/priv/emqx_retainer.schema | 30 + apps/emqx_retainer/rebar.config | 24 + apps/emqx_retainer/src/emqx_retainer.app.src | 14 + .../emqx_retainer/src/emqx_retainer.appup.src | 15 + apps/emqx_retainer/src/emqx_retainer.erl | 305 ++ apps/emqx_retainer/src/emqx_retainer_app.erl | 37 + apps/emqx_retainer/src/emqx_retainer_cli.erl | 58 + apps/emqx_retainer/src/emqx_retainer_sup.erl | 36 + .../test/emqx_retainer_SUITE.erl | 195 ++ .../test/emqx_retainer_cli_SUITE.erl | 40 + .../test/mqtt_protocol_v5_SUITE.erl | 147 + apps/emqx_rule_engine/.gitignore | 25 + apps/emqx_rule_engine/README.md | 50 + apps/emqx_rule_engine/docs/api_examples.md | 197 ++ apps/emqx_rule_engine/docs/cli_examples.md | 164 + apps/emqx_rule_engine/docs/design.md | 188 ++ .../etc/emqx_rule_engine.conf | 42 + .../emqx_rule_engine/include/rule_actions.hrl | 11 + apps/emqx_rule_engine/include/rule_engine.hrl | 181 ++ .../priv/emqx_rule_engine.schema | 61 + apps/emqx_rule_engine/rebar.config | 25 + .../src/emqx_rule_actions.erl | 208 ++ .../src/emqx_rule_engine.app.src | 14 + .../src/emqx_rule_engine.appup.src | 14 + .../emqx_rule_engine/src/emqx_rule_engine.erl | 646 ++++ .../src/emqx_rule_engine_api.erl | 554 ++++ .../src/emqx_rule_engine_app.erl | 38 + .../src/emqx_rule_engine_cli.erl | 387 +++ .../src/emqx_rule_engine_sup.erl | 63 + .../emqx_rule_engine/src/emqx_rule_events.erl | 622 ++++ apps/emqx_rule_engine/src/emqx_rule_funcs.erl | 912 ++++++ apps/emqx_rule_engine/src/emqx_rule_id.erl | 57 + .../emqx_rule_engine/src/emqx_rule_locker.erl | 34 + apps/emqx_rule_engine/src/emqx_rule_maps.erl | 209 ++ .../src/emqx_rule_metrics.erl | 440 +++ .../src/emqx_rule_monitor.erl | 127 + .../src/emqx_rule_registry.erl | 494 +++ .../src/emqx_rule_runtime.erl | 446 +++ .../src/emqx_rule_sqlparser.erl | 108 + .../src/emqx_rule_sqltester.erl | 118 + apps/emqx_rule_engine/src/emqx_rule_utils.erl | 358 +++ .../src/emqx_rule_validator.erl | 195 ++ .../test/emqx_rule_engine_SUITE.erl | 2657 +++++++++++++++++ .../test/emqx_rule_events_SUITE.erl | 31 + .../test/emqx_rule_funcs_SUITE.erl | 825 +++++ .../test/emqx_rule_id_SUITE.erl | 28 + .../test/emqx_rule_maps_SUITE.erl | 175 ++ .../test/emqx_rule_metrics_SUITE.erl | 169 ++ .../test/emqx_rule_monitor_SUITE.erl | 107 + .../test/emqx_rule_registry_SUITE.erl | 148 + .../test/emqx_rule_utils_SUITE.erl | 136 + .../test/emqx_rule_validator_SUITE.erl | 191 ++ apps/emqx_rule_engine/test/prop_rule_maps.erl | 10 + apps/emqx_sasl/.gitignore | 26 + apps/emqx_sasl/README.md | 2 + apps/emqx_sasl/etc/emqx_sasl.conf | 0 apps/emqx_sasl/include/emqx_sasl.hrl | 19 + apps/emqx_sasl/priv/emqx_sasl.schema | 0 apps/emqx_sasl/rebar.config | 19 + apps/emqx_sasl/src/emqx_sasl.app.src | 14 + apps/emqx_sasl/src/emqx_sasl.erl | 56 + apps/emqx_sasl/src/emqx_sasl_api.erl | 227 ++ apps/emqx_sasl/src/emqx_sasl_app.erl | 46 + apps/emqx_sasl/src/emqx_sasl_cli.erl | 82 + apps/emqx_sasl/src/emqx_sasl_scram.erl | 310 ++ apps/emqx_sasl/test/emqx_sasl_scram_SUITE.erl | 140 + apps/emqx_web_hook/.gitignore | 31 + apps/emqx_web_hook/README.md | 194 ++ apps/emqx_web_hook/TODO | 3 + apps/emqx_web_hook/etc/emqx_web_hook.conf | 77 + apps/emqx_web_hook/include/emqx_web_hook.hrl | 1 + apps/emqx_web_hook/priv/emqx_web_hook.schema | 105 + apps/emqx_web_hook/rebar.config | 18 + apps/emqx_web_hook/src/emqx_web_hook.app.src | 14 + .../emqx_web_hook/src/emqx_web_hook.appup.src | 10 + apps/emqx_web_hook/src/emqx_web_hook.erl | 390 +++ .../src/emqx_web_hook_actions.erl | 371 +++ apps/emqx_web_hook/src/emqx_web_hook_app.erl | 99 + apps/emqx_web_hook/src/emqx_web_hook_sup.erl | 29 + .../test/emqx_web_hook_SUITE.erl | 284 ++ .../test/emqx_web_hook_SUITE_data/ca.pem | 19 + .../emqx_web_hook_SUITE_data/client-cert.pem | 19 + .../emqx_web_hook_SUITE_data/client-key.pem | 27 + .../emqx_web_hook_SUITE_data/server-cert.pem | 19 + .../emqx_web_hook_SUITE_data/server-key.pem | 27 + apps/emqx_web_hook/test/http_server.erl | 102 + .../test/props/prop_webhook_confs.erl | 146 + .../test/props/prop_webhook_hooks.erl | 397 +++ bin/dgiot_ctl | 96 - bin/dgiot_env | 11 - bin/{dgiot => emqx} | 336 ++- bin/{dgiot.cmd => emqx.cmd} | 26 +- bin/emqx_ctl | 84 + bin/{dgiot_ctl.cmd => emqx_ctl.cmd} | 18 +- bin/install_upgrade.escript | 377 +++ bin/install_upgrade_escript | 143 - bin/node_dump | 82 + bin/nodetool | 90 +- build | 147 + data/emqx_vars | 24 + data/loaded_modules.tmpl | 3 +- data/loaded_plugins.tmpl | 9 +- deploy/charts/emqx/Chart.yaml | 4 +- deploy/charts/emqx/README.md | 18 +- deploy/charts/emqx/templates/StatefulSet.yaml | 54 +- deploy/charts/emqx/templates/configmap.yaml | 47 +- .../emqx/templates/configmap_for_acl.yaml | 13 - deploy/charts/emqx/templates/ingress.yaml | 70 + deploy/charts/emqx/templates/service.yaml | 19 + deploy/charts/emqx/values.yaml | 83 +- deploy/docker/Dockerfile | 49 +- deploy/docker/Makefile | 184 -- deploy/docker/README.md | 127 +- deploy/docker/docker-entrypoint.sh | 152 +- deploy/docker/start.sh | 53 - deploy/packages/Makefile | 60 - deploy/packages/README.md | 24 - deploy/packages/deb/Makefile | 18 +- deploy/packages/deb/debian/postrm | 3 + deploy/packages/deb/debian/rules | 12 +- deploy/packages/rpm/Makefile | 19 +- deploy/packages/rpm/emqx.spec | 17 +- deploy/packages/rpm/init.script | 21 +- dgiot.rebar.config | 210 -- dgiot_linux.ipr | 34 + dgiot_linux.iws | 49 + dgiot_server.iml | 20 + docker.mk | 186 ++ elvis.config | 47 + etc/BUILT_ON | 1 + etc/acl.conf | 26 + etc/acl.conf.paho | 14 + etc/certs/README | 1 + etc/certs/cacert.pem | 20 + etc/certs/cert.pem | 19 + etc/certs/client-cert.pem | 19 + etc/certs/client-key.pem | 27 + etc/certs/key.pem | 27 + etc/emqx.conf | 2443 +++++++++++++++ etc/emqx_cloud/vm.args | 118 + etc/emqx_edge/vm.args | 116 + etc/ssl_dist.conf | 11 + include/emqx.hrl | 135 + include/emqx_mqtt.hrl | 543 ++++ include/emqx_release.hrl | 39 + include/logger.hrl | 50 + include/types.hrl | 26 + lib-ce/emqx_dashboard/.gitignore | 25 + lib-ce/emqx_dashboard/README.md | 88 + lib-ce/emqx_dashboard/etc/emqx_dashboard.conf | 130 + .../emqx_dashboard/include/emqx_dashboard.hrl | 21 + .../emqx_dashboard/priv/emqx_dashboard.schema | 152 + lib-ce/emqx_dashboard/rebar.config | 15 + .../emqx_dashboard/src/emqx_dashboard.app.src | 14 + lib-ce/emqx_dashboard/src/emqx_dashboard.erl | 124 + .../src/emqx_dashboard_admin.erl | 228 ++ .../emqx_dashboard/src/emqx_dashboard_api.erl | 109 + .../emqx_dashboard/src/emqx_dashboard_app.erl | 35 + .../emqx_dashboard/src/emqx_dashboard_cli.erl | 56 + .../emqx_dashboard/src/emqx_dashboard_sup.erl | 32 + lib-ce/emqx_dashboard/test/.placeholder | 0 .../test/emqx_dashboard_SUITE.erl | 163 + lib-ce/emqx_modules/etc/emqx_modules.conf | 1 + lib-ce/emqx_modules/priv/emqx_modules.schema | 1 + lib-ce/emqx_modules/rebar.config | 1 + .../src/emqx_mod_acl_internal.erl | 122 + .../src/emqx_mod_api_topic_metrics.erl | 203 ++ lib-ce/emqx_modules/src/emqx_mod_delayed.erl | 225 ++ lib-ce/emqx_modules/src/emqx_mod_presence.erl | 130 + lib-ce/emqx_modules/src/emqx_mod_rewrite.erl | 103 + .../src/emqx_mod_subscription.erl | 65 + lib-ce/emqx_modules/src/emqx_mod_sup.erl | 74 + .../src/emqx_mod_topic_metrics.erl | 403 +++ lib-ce/emqx_modules/src/emqx_modules.app.src | 9 + .../emqx_modules/src/emqx_modules.appup.src | 15 + lib-ce/emqx_modules/src/emqx_modules.erl | 215 ++ lib-ce/emqx_modules/src/emqx_modules_api.erl | 164 + lib-ce/emqx_modules/src/emqx_modules_app.erl | 36 + .../test/emqx_mod_acl_internal_SUITE.erl | 64 + .../test/emqx_mod_delayed_SUITE.erl | 78 + .../test/emqx_mod_presence_SUITE.erl | 88 + .../test/emqx_mod_rewrite_SUITE.erl | 93 + .../test/emqx_mod_subscription_SUITE.erl | 92 + .../emqx_modules/test/emqx_mod_sup_SUITE.erl | 49 + .../test/emqx_mod_topic_metrics_SUITE.erl | 95 + .../emqx_modules/test/emqx_modules_SUITE.erl | 203 ++ lib-extra/README.md | 86 + lib-extra/emqx_plugin_template | 1 + lib-extra/plugins | 9 + pkg-vsn.sh | 21 + post-compile.cmd | 53 - post-compile.sh | 33 - priv/emqx.schema | 2481 +++++++++++++++ rebar.config | 146 +- rebar.config.erl | 467 +++ rebar.config.script | 215 -- rebar3 | Bin 858128 -> 1019803 bytes rebar3.cmd | 4 - relx | Bin 206934 -> 0 bytes scripts/apps-version-check.sh | 33 + scripts/check-deps-integrity.escript | 63 + scripts/elvis-check.sh | 60 + scripts/ensure-rebar3.sh | 28 + scripts/fail-on-old-otp-version.escript | 12 + scripts/find-apps.sh | 26 + scripts/find-props.sh | 16 + scripts/find-suites.sh | 15 + scripts/get-dashboard.sh | 59 + scripts/git-hook-pre-push.sh | 12 + scripts/git-hooks-init.sh | 13 + scripts/shellcheck.sh | 15 + scripts/split-config.escript | 63 + scripts/start-two-nodes-in-docker.sh | 66 + src/emqx.app.src | 15 + src/emqx.appup.src | 26 + src/emqx.erl | 257 ++ src/emqx_access_control.erl | 83 + src/emqx_access_rule.erl | 152 + src/emqx_acl_cache.erl | 256 ++ src/emqx_alarm.erl | 385 +++ src/emqx_alarm_handler.erl | 88 + src/emqx_app.erl | 134 + src/emqx_banned.erl | 163 + src/emqx_base62.erl | 106 + src/emqx_batch.erl | 91 + src/emqx_boot.erl | 29 + src/emqx_broker.erl | 501 ++++ src/emqx_broker_bench.erl | 186 ++ src/emqx_broker_helper.erl | 165 + src/emqx_broker_sup.erl | 55 + src/emqx_channel.erl | 1714 +++++++++++ src/emqx_cm.erl | 439 +++ src/emqx_cm_locker.erl | 66 + src/emqx_cm_registry.erl | 153 + src/emqx_cm_sup.erl | 70 + src/emqx_congestion.erl | 142 + src/emqx_connection.erl | 819 +++++ src/emqx_ctl.erl | 234 ++ src/emqx_flapping.erl | 163 + src/emqx_frame.erl | 813 +++++ src/emqx_gc.erl | 116 + src/emqx_gen_mod.erl | 23 + src/emqx_global_gc.erl | 102 + src/emqx_guid.erl | 150 + src/emqx_hooks.erl | 291 ++ src/emqx_http_lib.erl | 177 ++ src/emqx_inflight.erl | 127 + src/emqx_json.erl | 124 + src/emqx_keepalive.erl | 73 + src/emqx_kernel_sup.erl | 57 + src/emqx_limiter.erl | 154 + src/emqx_listeners.erl | 278 ++ src/emqx_logger.erl | 337 +++ src/emqx_logger_jsonfmt.erl | 295 ++ src/emqx_logger_textfmt.erl | 49 + src/emqx_message.erl | 351 +++ src/emqx_metrics.erl | 578 ++++ src/emqx_misc.erl | 293 ++ src/emqx_mountpoint.erl | 79 + src/emqx_mqtt_caps.erl | 160 + src/emqx_mqtt_props.erl | 197 ++ src/emqx_mqueue.erl | 196 ++ src/emqx_node_dump.erl | 75 + src/emqx_os_mon.erl | 179 ++ src/emqx_packet.erl | 523 ++++ src/emqx_passwd.erl | 96 + src/emqx_pd.erl | 52 + src/emqx_plugins.erl | 378 +++ src/emqx_pmon.erl | 96 + src/emqx_pool.erl | 138 + src/emqx_pool_sup.erl | 85 + src/emqx_pqueue.erl | 269 ++ src/emqx_psk.erl | 40 + src/emqx_reason_codes.erl | 185 ++ src/emqx_router.erl | 316 ++ src/emqx_router_helper.erl | 179 ++ src/emqx_router_sup.erl | 45 + src/emqx_rpc.erl | 74 + src/emqx_rule_actions_trans.erl | 70 + src/emqx_sequence.erl | 73 + src/emqx_session.erl | 699 +++++ src/emqx_shared_sub.erl | 399 +++ src/emqx_stats.erl | 277 ++ src/emqx_sup.erl | 102 + src/emqx_sys.erl | 225 ++ src/emqx_sys_mon.erl | 194 ++ src/emqx_sys_sup.erl | 53 + src/emqx_tables.erl | 65 + src/emqx_tls_lib.erl | 198 ++ src/emqx_topic.erl | 221 ++ src/emqx_tracer.erl | 168 ++ src/emqx_trie.erl | 347 +++ src/emqx_types.erl | 215 ++ src/emqx_vm.erl | 397 +++ src/emqx_vm_mon.erl | 141 + src/emqx_ws_connection.erl | 774 +++++ src/emqx_zone.erl | 298 ++ test/emqx_SUITE.erl | 195 ++ test/emqx_SUITE_data/acl.conf | 29 + test/emqx_SUITE_data/loaded_modules | 2 + test/emqx_SUITE_data/loaded_plugins | 0 test/emqx_access_SUITE_data/acl.conf | 15 + .../acl_deny_action.conf | 3 + test/emqx_access_control_SUITE.erl | 81 + test/emqx_access_rule_SUITE.erl | 97 + test/emqx_acl_cache_SUITE.erl | 148 + test/emqx_acl_test_mod.erl | 33 + test/emqx_alarm_SUITE.erl | 112 + test/emqx_banned_SUITE.erl | 95 + test/emqx_batch_SUITE.erl | 57 + test/emqx_boot_SUITE.erl | 43 + test/emqx_broker_SUITE.erl | 221 ++ test/emqx_broker_helper_SUITE.erl | 75 + test/emqx_channel_SUITE.erl | 838 ++++++ test/emqx_client_SUITE.erl | 338 +++ test/emqx_cm_SUITE.erl | 229 ++ test/emqx_cm_locker_SUITE.erl | 45 + test/emqx_cm_registry_SUITE.erl | 78 + test/emqx_connection_SUITE.erl | 529 ++++ test/emqx_ctl_SUITE.erl | 118 + test/emqx_flapping_SUITE.erl | 75 + test/emqx_frame_SUITE.erl | 534 ++++ test/emqx_gc_SUITE.erl | 60 + test/emqx_global_gc_SUITE.erl | 33 + test/emqx_guid_SUITE.erl | 41 + test/emqx_hooks_SUITE.erl | 143 + test/emqx_http_lib_tests.erl | 84 + test/emqx_inflight_SUITE.erl | 94 + test/emqx_json_SUITE.erl | 124 + test/emqx_keepalive_SUITE.erl | 42 + test/emqx_limiter_SUITE.erl | 78 + test/emqx_listeners_SUITE.erl | 94 + test/emqx_logger_SUITE.erl | 181 ++ test/emqx_message_SUITE.erl | 224 ++ test/emqx_metrics_SUITE.erl | 182 ++ test/emqx_misc_SUITE.erl | 148 + test/emqx_mountpoint_SUITE.erl | 67 + test/emqx_mqtt_SUITE.erl | 136 + test/emqx_mqtt_caps_SUITE.erl | 63 + test/emqx_mqtt_props_SUITE.erl | 89 + test/emqx_mqueue_SUITE.erl | 165 + test/emqx_os_mon_SUITE.erl | 72 + test/emqx_packet_SUITE.erl | 315 ++ test/emqx_passwd_SUITE.erl | 31 + test/emqx_pd_SUITE.erl | 33 + test/emqx_plugins_SUITE.erl | 145 + .../emqx_mini_plugin/Makefile | 35 + .../etc/emqx_mini_plugin.conf | 1 + .../priv/emqx_mini_plugin.schema | 5 + .../emqx_mini_plugin/rebar.config | 25 + .../src/emqx_mini_plugin.app.src | 14 + .../src/emqx_mini_plugin_app.erl | 42 + test/emqx_pmon_SUITE.erl | 64 + test/emqx_pool_SUITE.erl | 90 + test/emqx_pqueue_SUITE.erl | 177 ++ test/emqx_reason_codes_SUITE.erl | 30 + test/emqx_request_handler.erl | 94 + test/emqx_request_responser_SUITE.erl | 70 + test/emqx_request_sender.erl | 77 + test/emqx_router_SUITE.erl | 120 + test/emqx_router_helper_SUITE.erl | 50 + test/emqx_sequence_SUITE.erl | 64 + test/emqx_session_SUITE.erl | 399 +++ test/emqx_shared_sub_SUITE.erl | 345 +++ test/emqx_stats_SUITE.erl | 121 + test/emqx_sup_SUITE.erl | 39 + test/emqx_sys_SUITE.erl | 60 + test/emqx_sys_mon_SUITE.erl | 122 + test/emqx_tables_SUITE.erl | 45 + test/emqx_takeover_SUITE.erl | 143 + test/emqx_tls_lib_tests.erl | 68 + test/emqx_topic_SUITE.erl | 219 ++ test/emqx_tracer_SUITE.erl | 120 + test/emqx_trie_SUITE.erl | 197 ++ test/emqx_vm_SUITE.erl | 99 + test/emqx_vm_mon_SUITE.erl | 65 + test/emqx_ws_connection_SUITE.erl | 569 ++++ test/emqx_zone_SUITE.erl | 104 + test/mqtt_protocol_v5_SUITE.erl | 771 +++++ test/props/prop_emqx_base62.erl | 72 + test/props/prop_emqx_frame.erl | 62 + test/props/prop_emqx_json.erl | 190 ++ test/props/prop_emqx_psk.erl | 66 + test/props/prop_emqx_reason_codes.erl | 123 + test/props/prop_emqx_rpc.erl | 170 ++ test/props/prop_emqx_sys.erl | 132 + vars-bin.config | 23 - vars-cloud.config | 2 - vars-edge.config | 2 - vars-pkg.config | 22 - 648 files changed, 90491 insertions(+), 1821 deletions(-) create mode 100644 .ci/build_packages/Dockerfile create mode 100644 .ci/build_packages/tests.sh create mode 100644 .ci/docker-compose-file/.env create mode 100644 .ci/docker-compose-file/conf.cluster.env create mode 100644 .ci/docker-compose-file/conf.env create mode 100644 .ci/docker-compose-file/docker-compose-emqx-cluster.yaml create mode 100644 .ci/docker-compose-file/docker-compose-ldap-tcp.yaml create mode 100644 .ci/docker-compose-file/docker-compose-mongo-tcp.yaml create mode 100644 .ci/docker-compose-file/docker-compose-mongo-tls.yaml create mode 100644 .ci/docker-compose-file/docker-compose-mysql-tcp.yaml create mode 100644 .ci/docker-compose-file/docker-compose-mysql-tls.yaml create mode 100644 .ci/docker-compose-file/docker-compose-pgsql-tcp.yaml create mode 100644 .ci/docker-compose-file/docker-compose-pgsql-tls.yaml create mode 100644 .ci/docker-compose-file/docker-compose-python.yaml create mode 100644 .ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml create mode 100644 .ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml create mode 100644 .ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml create mode 100644 .ci/docker-compose-file/docker-compose-redis-sentinel-tls.yaml create mode 100644 .ci/docker-compose-file/docker-compose-redis-single-tcp.yaml create mode 100644 .ci/docker-compose-file/docker-compose-redis-single-tls.yaml create mode 100644 .ci/docker-compose-file/docker-compose.yaml create mode 100644 .ci/docker-compose-file/haproxy/haproxy.cfg create mode 100644 .ci/docker-compose-file/openldap/Dockerfile create mode 100644 .ci/docker-compose-file/openldap/slapd.conf create mode 100644 .ci/docker-compose-file/pgsql/Dockerfile create mode 100644 .ci/docker-compose-file/pgsql/pg_hba.conf create mode 100644 .ci/docker-compose-file/python/pytest.sh create mode 100644 .ci/docker-compose-file/redis/redis-tls.conf create mode 100644 .ci/docker-compose-file/redis/redis.conf create mode 100644 .ci/docker-compose-file/redis/redis.sh create mode 100644 .ci/fvt_tests/.env create mode 100644 .ci/fvt_tests/http_server/README.md create mode 100644 .ci/fvt_tests/http_server/rebar.config create mode 100644 .ci/fvt_tests/http_server/src/http_server.app.src create mode 100644 .ci/fvt_tests/http_server/src/http_server.erl create mode 100644 .ci/fvt_tests/relup.lux create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/support-needed.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/weekly-digest.yml create mode 100644 .github/workflows/.gitlint create mode 100644 .github/workflows/apps_version_check.yaml create mode 100644 .github/workflows/build_packages.yaml create mode 100644 .github/workflows/build_slim_packages.yaml create mode 100644 .github/workflows/check_deps_integrity.yaml create mode 100644 .github/workflows/elvis_lint.yaml create mode 100644 .github/workflows/git_sync.yaml delete mode 100644 .github/workflows/gitee-repos-mirror.yml create mode 100644 .github/workflows/run_cts_tests.yaml create mode 100644 .github/workflows/run_fvt_tests.yaml create mode 100644 .github/workflows/run_gitlint.yaml create mode 100644 .github/workflows/run_test_cases.yaml create mode 100644 .github/workflows/shellcheck.yaml create mode 100644 .tool-versions create mode 100644 CONTRIBUTING.md create mode 100644 README-CN.md create mode 100644 README-JP.md create mode 100644 README-RU.md create mode 100644 Windows.md create mode 100644 apps/.gitkeep create mode 100644 apps/emqx_bridge_mqtt/.gitignore create mode 100644 apps/emqx_bridge_mqtt/README.md create mode 100644 apps/emqx_bridge_mqtt/docs/guide.rst create mode 100644 apps/emqx_bridge_mqtt/docs/images/bridge.png create mode 100644 apps/emqx_bridge_mqtt/etc/emqx_bridge_mqtt.conf create mode 100644 apps/emqx_bridge_mqtt/include/emqx_bridge_mqtt.hrl create mode 100644 apps/emqx_bridge_mqtt/priv/emqx_bridge_mqtt.schema create mode 100644 apps/emqx_bridge_mqtt/rebar.config create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_connect.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.app.src create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.appup.src create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_actions.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_app.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_cli.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_sup.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_msg.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_rpc.erl create mode 100644 apps/emqx_bridge_mqtt/src/emqx_bridge_worker.erl create mode 100644 apps/emqx_bridge_mqtt/test/emqx_bridge_mqtt_tests.erl create mode 100644 apps/emqx_bridge_mqtt/test/emqx_bridge_rpc_tests.erl create mode 100644 apps/emqx_bridge_mqtt/test/emqx_bridge_stub_conn.erl create mode 100644 apps/emqx_bridge_mqtt/test/emqx_bridge_worker_SUITE.erl create mode 100644 apps/emqx_bridge_mqtt/test/emqx_bridge_worker_tests.erl create mode 100644 apps/emqx_exhook/.gitignore create mode 100644 apps/emqx_exhook/README.md create mode 100644 apps/emqx_exhook/docs/design-cn.md create mode 100644 apps/emqx_exhook/etc/emqx_exhook.conf create mode 100644 apps/emqx_exhook/include/emqx_exhook.hrl create mode 100644 apps/emqx_exhook/priv/emqx_exhook.schema create mode 100644 apps/emqx_exhook/priv/protos/exhook.proto create mode 100644 apps/emqx_exhook/rebar.config create mode 100644 apps/emqx_exhook/src/emqx_exhook.app.src create mode 100644 apps/emqx_exhook/src/emqx_exhook.erl create mode 100644 apps/emqx_exhook/src/emqx_exhook_app.erl create mode 100644 apps/emqx_exhook/src/emqx_exhook_cli.erl create mode 100644 apps/emqx_exhook/src/emqx_exhook_handler.erl create mode 100644 apps/emqx_exhook/src/emqx_exhook_server.erl create mode 100644 apps/emqx_exhook/src/emqx_exhook_sup.erl create mode 100644 apps/emqx_exhook/test/emqx_exhook_SUITE.erl create mode 100644 apps/emqx_exhook/test/emqx_exhook_demo_svr.erl create mode 100644 apps/emqx_exhook/test/props/prop_exhook_hooks.erl create mode 100644 apps/emqx_exproto/.gitignore create mode 100644 apps/emqx_exproto/README.md create mode 100644 apps/emqx_exproto/docs/design-cn.md create mode 100644 apps/emqx_exproto/docs/images/exproto-arch.jpg create mode 100644 apps/emqx_exproto/docs/images/exproto-grpc-arch.jpg create mode 100644 apps/emqx_exproto/etc/emqx_exproto.conf create mode 100644 apps/emqx_exproto/include/emqx_exproto.hrl create mode 100644 apps/emqx_exproto/priv/emqx_exproto.schema create mode 100644 apps/emqx_exproto/priv/protos/exproto.proto create mode 100644 apps/emqx_exproto/rebar.config create mode 100644 apps/emqx_exproto/src/emqx_exproto.app.src create mode 100644 apps/emqx_exproto/src/emqx_exproto.erl create mode 100644 apps/emqx_exproto/src/emqx_exproto_app.erl create mode 100644 apps/emqx_exproto/src/emqx_exproto_channel.erl create mode 100644 apps/emqx_exproto/src/emqx_exproto_conn.erl create mode 100644 apps/emqx_exproto/src/emqx_exproto_gcli.erl create mode 100644 apps/emqx_exproto/src/emqx_exproto_gsvr.erl create mode 100644 apps/emqx_exproto/src/emqx_exproto_sup.erl create mode 100644 apps/emqx_exproto/test/emqx_exproto_SUITE.erl create mode 100644 apps/emqx_exproto/test/emqx_exproto_echo_svr.erl create mode 100644 apps/emqx_lua_hook/.gitignore create mode 100644 apps/emqx_lua_hook/README.md create mode 100644 apps/emqx_lua_hook/etc/emqx_lua_hook.conf create mode 100644 apps/emqx_lua_hook/examples.lua create mode 100644 apps/emqx_lua_hook/include/emqx_lua_hook.hrl create mode 100644 apps/emqx_lua_hook/priv/emqx_lua_hook.schema create mode 100644 apps/emqx_lua_hook/rebar.config create mode 100644 apps/emqx_lua_hook/src/emqx_lua_hook.app.src create mode 100644 apps/emqx_lua_hook/src/emqx_lua_hook.erl create mode 100644 apps/emqx_lua_hook/src/emqx_lua_hook_app.erl create mode 100644 apps/emqx_lua_hook/src/emqx_lua_hook_cli.erl create mode 100644 apps/emqx_lua_hook/src/emqx_lua_hook_sup.erl create mode 100644 apps/emqx_lua_hook/src/emqx_lua_script.erl create mode 100644 apps/emqx_lua_hook/test/emqx_lua_hook_SUITE.erl create mode 100644 apps/emqx_management/.gitignore create mode 100644 apps/emqx_management/README.md create mode 100644 apps/emqx_management/etc/emqx_management.conf create mode 100644 apps/emqx_management/include/emqx_mgmt.hrl create mode 100644 apps/emqx_management/priv/emqx_management.schema create mode 100644 apps/emqx_management/rebar.config create mode 100644 apps/emqx_management/src/emqx_management.app.src create mode 100644 apps/emqx_management/src/emqx_management.appup.src create mode 100644 apps/emqx_management/src/emqx_mgmt.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_acl.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_alarms.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_apps.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_banned.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_brokers.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_clients.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_data.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_listeners.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_metrics.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_nodes.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_plugins.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_pubsub.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_routes.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_stats.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_api_subscriptions.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_app.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_auth.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_cli.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_data_backup.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_http.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_sup.erl create mode 100644 apps/emqx_management/src/emqx_mgmt_util.erl create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE.erl create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/make_data.sh create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/v4.0.11-no-auth.json create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/v4.0.11.json create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/v4.0.13.json create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/v4.1.5.json create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/v4.2.10-no-auth.json create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/v4.2.10.json create mode 100644 apps/emqx_management/test/emqx_auth_mnesia_migration_SUITE_data/v4.2.11.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE.erl create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/409.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/415.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/420.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/430.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee4010.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee410.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee411.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee420.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee425.json create mode 100644 apps/emqx_management/test/emqx_bridge_mqtt_data_export_import_SUITE_data/ee430.json create mode 100644 apps/emqx_management/test/emqx_mgmt_SUITE.erl create mode 100644 apps/emqx_management/test/emqx_mgmt_api_SUITE.erl create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE.erl create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/409.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/415.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/422.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/423.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/425.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/430.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee4010.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee410.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee411.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee420.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee425.json create mode 100644 apps/emqx_management/test/emqx_webhook_data_export_import_SUITE_data/ee430.json create mode 100644 apps/emqx_management/test/etc/emqx_management.conf create mode 100644 apps/emqx_management/test/etc/emqx_reloader.conf create mode 100644 apps/emqx_management/test/rfc6455_client.erl create mode 100644 apps/emqx_management/test/test_utils.erl create mode 100644 apps/emqx_plugin_libs/src/emqx_plugin_libs.app.src create mode 100644 apps/emqx_plugin_libs/src/emqx_plugin_libs.erl create mode 100644 apps/emqx_plugin_libs/src/emqx_plugin_libs_ssl.erl create mode 100644 apps/emqx_plugin_libs/test/emqx_plugin_libs_ssl_tests.erl create mode 100644 apps/emqx_prometheus/.gitignore create mode 100644 apps/emqx_prometheus/README.md create mode 100644 apps/emqx_prometheus/TODO create mode 100644 apps/emqx_prometheus/etc/emqx_prometheus.conf create mode 100644 apps/emqx_prometheus/grafana_template/EMQ.json create mode 100644 apps/emqx_prometheus/grafana_template/EMQ_Dashboard.json create mode 100644 apps/emqx_prometheus/grafana_template/ErlangVM.json create mode 100644 apps/emqx_prometheus/include/emqx_prometheus.hrl create mode 100644 apps/emqx_prometheus/priv/emqx_prometheus.schema create mode 100644 apps/emqx_prometheus/rebar.config create mode 100644 apps/emqx_prometheus/src/emqx_prometheus.app.src create mode 100644 apps/emqx_prometheus/src/emqx_prometheus.erl create mode 100644 apps/emqx_prometheus/src/emqx_prometheus_app.erl create mode 100644 apps/emqx_prometheus/src/emqx_prometheus_sup.erl create mode 100644 apps/emqx_prometheus/test/emqx_prometheus_SUITE.erl create mode 100644 apps/emqx_psk_file/.gitignore create mode 100644 apps/emqx_psk_file/README.md create mode 100644 apps/emqx_psk_file/etc/emqx_psk_file.conf create mode 100644 apps/emqx_psk_file/etc/psk.txt create mode 100644 apps/emqx_psk_file/priv/emqx_psk_file.schema create mode 100644 apps/emqx_psk_file/rebar.config create mode 100644 apps/emqx_psk_file/src/emqx_psk_file.app.src create mode 100644 apps/emqx_psk_file/src/emqx_psk_file.erl create mode 100644 apps/emqx_psk_file/src/emqx_psk_file_app.erl create mode 100644 apps/emqx_psk_file/src/emqx_psk_file_sup.erl create mode 100644 apps/emqx_psk_file/test/emqx_psk_file_SUITE.erl create mode 100644 apps/emqx_recon/.gitignore create mode 100644 apps/emqx_recon/README.md create mode 100644 apps/emqx_recon/etc/emqx_recon.conf create mode 100644 apps/emqx_recon/priv/emqx_recon.schema create mode 100644 apps/emqx_recon/rebar.config create mode 100644 apps/emqx_recon/src/emqx_recon.app.src create mode 100644 apps/emqx_recon/src/emqx_recon.erl create mode 100644 apps/emqx_recon/src/emqx_recon_cli.erl create mode 100644 apps/emqx_recon/test/emqx_recon_SUITE.erl create mode 100644 apps/emqx_retainer/.gitignore create mode 100644 apps/emqx_retainer/README.md create mode 100644 apps/emqx_retainer/TODO create mode 100644 apps/emqx_retainer/etc/emqx_retainer.conf create mode 100644 apps/emqx_retainer/include/emqx_retainer.hrl create mode 100644 apps/emqx_retainer/priv/emqx_retainer.schema create mode 100644 apps/emqx_retainer/rebar.config create mode 100644 apps/emqx_retainer/src/emqx_retainer.app.src create mode 100644 apps/emqx_retainer/src/emqx_retainer.appup.src create mode 100644 apps/emqx_retainer/src/emqx_retainer.erl create mode 100644 apps/emqx_retainer/src/emqx_retainer_app.erl create mode 100644 apps/emqx_retainer/src/emqx_retainer_cli.erl create mode 100644 apps/emqx_retainer/src/emqx_retainer_sup.erl create mode 100644 apps/emqx_retainer/test/emqx_retainer_SUITE.erl create mode 100644 apps/emqx_retainer/test/emqx_retainer_cli_SUITE.erl create mode 100644 apps/emqx_retainer/test/mqtt_protocol_v5_SUITE.erl create mode 100644 apps/emqx_rule_engine/.gitignore create mode 100644 apps/emqx_rule_engine/README.md create mode 100644 apps/emqx_rule_engine/docs/api_examples.md create mode 100644 apps/emqx_rule_engine/docs/cli_examples.md create mode 100644 apps/emqx_rule_engine/docs/design.md create mode 100644 apps/emqx_rule_engine/etc/emqx_rule_engine.conf create mode 100644 apps/emqx_rule_engine/include/rule_actions.hrl create mode 100644 apps/emqx_rule_engine/include/rule_engine.hrl create mode 100644 apps/emqx_rule_engine/priv/emqx_rule_engine.schema create mode 100644 apps/emqx_rule_engine/rebar.config create mode 100644 apps/emqx_rule_engine/src/emqx_rule_actions.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_engine.app.src create mode 100644 apps/emqx_rule_engine/src/emqx_rule_engine.appup.src create mode 100644 apps/emqx_rule_engine/src/emqx_rule_engine.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_engine_api.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_engine_app.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_engine_cli.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_engine_sup.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_events.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_funcs.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_id.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_locker.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_maps.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_metrics.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_monitor.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_registry.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_runtime.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_sqlparser.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_sqltester.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_utils.erl create mode 100644 apps/emqx_rule_engine/src/emqx_rule_validator.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_engine_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_events_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_funcs_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_id_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_maps_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_metrics_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_monitor_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_registry_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_utils_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/emqx_rule_validator_SUITE.erl create mode 100644 apps/emqx_rule_engine/test/prop_rule_maps.erl create mode 100644 apps/emqx_sasl/.gitignore create mode 100644 apps/emqx_sasl/README.md create mode 100644 apps/emqx_sasl/etc/emqx_sasl.conf create mode 100644 apps/emqx_sasl/include/emqx_sasl.hrl create mode 100644 apps/emqx_sasl/priv/emqx_sasl.schema create mode 100644 apps/emqx_sasl/rebar.config create mode 100644 apps/emqx_sasl/src/emqx_sasl.app.src create mode 100644 apps/emqx_sasl/src/emqx_sasl.erl create mode 100644 apps/emqx_sasl/src/emqx_sasl_api.erl create mode 100644 apps/emqx_sasl/src/emqx_sasl_app.erl create mode 100644 apps/emqx_sasl/src/emqx_sasl_cli.erl create mode 100644 apps/emqx_sasl/src/emqx_sasl_scram.erl create mode 100644 apps/emqx_sasl/test/emqx_sasl_scram_SUITE.erl create mode 100644 apps/emqx_web_hook/.gitignore create mode 100644 apps/emqx_web_hook/README.md create mode 100644 apps/emqx_web_hook/TODO create mode 100644 apps/emqx_web_hook/etc/emqx_web_hook.conf create mode 100644 apps/emqx_web_hook/include/emqx_web_hook.hrl create mode 100644 apps/emqx_web_hook/priv/emqx_web_hook.schema create mode 100644 apps/emqx_web_hook/rebar.config create mode 100644 apps/emqx_web_hook/src/emqx_web_hook.app.src create mode 100644 apps/emqx_web_hook/src/emqx_web_hook.appup.src create mode 100644 apps/emqx_web_hook/src/emqx_web_hook.erl create mode 100644 apps/emqx_web_hook/src/emqx_web_hook_actions.erl create mode 100644 apps/emqx_web_hook/src/emqx_web_hook_app.erl create mode 100644 apps/emqx_web_hook/src/emqx_web_hook_sup.erl create mode 100644 apps/emqx_web_hook/test/emqx_web_hook_SUITE.erl create mode 100644 apps/emqx_web_hook/test/emqx_web_hook_SUITE_data/ca.pem create mode 100644 apps/emqx_web_hook/test/emqx_web_hook_SUITE_data/client-cert.pem create mode 100644 apps/emqx_web_hook/test/emqx_web_hook_SUITE_data/client-key.pem create mode 100644 apps/emqx_web_hook/test/emqx_web_hook_SUITE_data/server-cert.pem create mode 100644 apps/emqx_web_hook/test/emqx_web_hook_SUITE_data/server-key.pem create mode 100644 apps/emqx_web_hook/test/http_server.erl create mode 100644 apps/emqx_web_hook/test/props/prop_webhook_confs.erl create mode 100644 apps/emqx_web_hook/test/props/prop_webhook_hooks.erl delete mode 100644 bin/dgiot_ctl delete mode 100644 bin/dgiot_env rename bin/{dgiot => emqx} (54%) rename bin/{dgiot.cmd => emqx.cmd} (92%) create mode 100644 bin/emqx_ctl rename bin/{dgiot_ctl.cmd => emqx_ctl.cmd} (87%) create mode 100644 bin/install_upgrade.escript delete mode 100644 bin/install_upgrade_escript create mode 100644 bin/node_dump create mode 100644 build create mode 100644 data/emqx_vars delete mode 100644 deploy/charts/emqx/templates/configmap_for_acl.yaml create mode 100644 deploy/charts/emqx/templates/ingress.yaml delete mode 100644 deploy/docker/Makefile delete mode 100644 deploy/docker/start.sh delete mode 100644 deploy/packages/Makefile delete mode 100644 deploy/packages/README.md delete mode 100644 dgiot.rebar.config create mode 100644 dgiot_linux.ipr create mode 100644 dgiot_linux.iws create mode 100644 dgiot_server.iml create mode 100644 docker.mk create mode 100644 elvis.config create mode 100644 etc/BUILT_ON create mode 100644 etc/acl.conf create mode 100644 etc/acl.conf.paho create mode 100644 etc/certs/README create mode 100644 etc/certs/cacert.pem create mode 100644 etc/certs/cert.pem create mode 100644 etc/certs/client-cert.pem create mode 100644 etc/certs/client-key.pem create mode 100644 etc/certs/key.pem create mode 100644 etc/emqx.conf create mode 100644 etc/emqx_cloud/vm.args create mode 100644 etc/emqx_edge/vm.args create mode 100644 etc/ssl_dist.conf create mode 100644 include/emqx.hrl create mode 100644 include/emqx_mqtt.hrl create mode 100644 include/emqx_release.hrl create mode 100644 include/logger.hrl create mode 100644 include/types.hrl create mode 100644 lib-ce/emqx_dashboard/.gitignore create mode 100644 lib-ce/emqx_dashboard/README.md create mode 100644 lib-ce/emqx_dashboard/etc/emqx_dashboard.conf create mode 100644 lib-ce/emqx_dashboard/include/emqx_dashboard.hrl create mode 100644 lib-ce/emqx_dashboard/priv/emqx_dashboard.schema create mode 100644 lib-ce/emqx_dashboard/rebar.config create mode 100644 lib-ce/emqx_dashboard/src/emqx_dashboard.app.src create mode 100644 lib-ce/emqx_dashboard/src/emqx_dashboard.erl create mode 100644 lib-ce/emqx_dashboard/src/emqx_dashboard_admin.erl create mode 100644 lib-ce/emqx_dashboard/src/emqx_dashboard_api.erl create mode 100644 lib-ce/emqx_dashboard/src/emqx_dashboard_app.erl create mode 100644 lib-ce/emqx_dashboard/src/emqx_dashboard_cli.erl create mode 100644 lib-ce/emqx_dashboard/src/emqx_dashboard_sup.erl create mode 100644 lib-ce/emqx_dashboard/test/.placeholder create mode 100644 lib-ce/emqx_dashboard/test/emqx_dashboard_SUITE.erl create mode 100644 lib-ce/emqx_modules/etc/emqx_modules.conf create mode 100644 lib-ce/emqx_modules/priv/emqx_modules.schema create mode 100644 lib-ce/emqx_modules/rebar.config create mode 100644 lib-ce/emqx_modules/src/emqx_mod_acl_internal.erl create mode 100644 lib-ce/emqx_modules/src/emqx_mod_api_topic_metrics.erl create mode 100644 lib-ce/emqx_modules/src/emqx_mod_delayed.erl create mode 100644 lib-ce/emqx_modules/src/emqx_mod_presence.erl create mode 100644 lib-ce/emqx_modules/src/emqx_mod_rewrite.erl create mode 100644 lib-ce/emqx_modules/src/emqx_mod_subscription.erl create mode 100644 lib-ce/emqx_modules/src/emqx_mod_sup.erl create mode 100644 lib-ce/emqx_modules/src/emqx_mod_topic_metrics.erl create mode 100644 lib-ce/emqx_modules/src/emqx_modules.app.src create mode 100644 lib-ce/emqx_modules/src/emqx_modules.appup.src create mode 100644 lib-ce/emqx_modules/src/emqx_modules.erl create mode 100644 lib-ce/emqx_modules/src/emqx_modules_api.erl create mode 100644 lib-ce/emqx_modules/src/emqx_modules_app.erl create mode 100644 lib-ce/emqx_modules/test/emqx_mod_acl_internal_SUITE.erl create mode 100644 lib-ce/emqx_modules/test/emqx_mod_delayed_SUITE.erl create mode 100644 lib-ce/emqx_modules/test/emqx_mod_presence_SUITE.erl create mode 100644 lib-ce/emqx_modules/test/emqx_mod_rewrite_SUITE.erl create mode 100644 lib-ce/emqx_modules/test/emqx_mod_subscription_SUITE.erl create mode 100644 lib-ce/emqx_modules/test/emqx_mod_sup_SUITE.erl create mode 100644 lib-ce/emqx_modules/test/emqx_mod_topic_metrics_SUITE.erl create mode 100644 lib-ce/emqx_modules/test/emqx_modules_SUITE.erl create mode 100644 lib-extra/README.md create mode 100644 lib-extra/emqx_plugin_template create mode 100644 lib-extra/plugins create mode 100644 pkg-vsn.sh delete mode 100644 post-compile.cmd delete mode 100644 post-compile.sh create mode 100644 priv/emqx.schema create mode 100644 rebar.config.erl delete mode 100644 rebar.config.script delete mode 100644 rebar3.cmd delete mode 100644 relx create mode 100644 scripts/apps-version-check.sh create mode 100644 scripts/check-deps-integrity.escript create mode 100644 scripts/elvis-check.sh create mode 100644 scripts/ensure-rebar3.sh create mode 100644 scripts/fail-on-old-otp-version.escript create mode 100644 scripts/find-apps.sh create mode 100644 scripts/find-props.sh create mode 100644 scripts/find-suites.sh create mode 100644 scripts/get-dashboard.sh create mode 100644 scripts/git-hook-pre-push.sh create mode 100644 scripts/git-hooks-init.sh create mode 100644 scripts/shellcheck.sh create mode 100644 scripts/split-config.escript create mode 100644 scripts/start-two-nodes-in-docker.sh create mode 100644 src/emqx.app.src create mode 100644 src/emqx.appup.src create mode 100644 src/emqx.erl create mode 100644 src/emqx_access_control.erl create mode 100644 src/emqx_access_rule.erl create mode 100644 src/emqx_acl_cache.erl create mode 100644 src/emqx_alarm.erl create mode 100644 src/emqx_alarm_handler.erl create mode 100644 src/emqx_app.erl create mode 100644 src/emqx_banned.erl create mode 100644 src/emqx_base62.erl create mode 100644 src/emqx_batch.erl create mode 100644 src/emqx_boot.erl create mode 100644 src/emqx_broker.erl create mode 100644 src/emqx_broker_bench.erl create mode 100644 src/emqx_broker_helper.erl create mode 100644 src/emqx_broker_sup.erl create mode 100644 src/emqx_channel.erl create mode 100644 src/emqx_cm.erl create mode 100644 src/emqx_cm_locker.erl create mode 100644 src/emqx_cm_registry.erl create mode 100644 src/emqx_cm_sup.erl create mode 100644 src/emqx_congestion.erl create mode 100644 src/emqx_connection.erl create mode 100644 src/emqx_ctl.erl create mode 100644 src/emqx_flapping.erl create mode 100644 src/emqx_frame.erl create mode 100644 src/emqx_gc.erl create mode 100644 src/emqx_gen_mod.erl create mode 100644 src/emqx_global_gc.erl create mode 100644 src/emqx_guid.erl create mode 100644 src/emqx_hooks.erl create mode 100644 src/emqx_http_lib.erl create mode 100644 src/emqx_inflight.erl create mode 100644 src/emqx_json.erl create mode 100644 src/emqx_keepalive.erl create mode 100644 src/emqx_kernel_sup.erl create mode 100644 src/emqx_limiter.erl create mode 100644 src/emqx_listeners.erl create mode 100644 src/emqx_logger.erl create mode 100644 src/emqx_logger_jsonfmt.erl create mode 100644 src/emqx_logger_textfmt.erl create mode 100644 src/emqx_message.erl create mode 100644 src/emqx_metrics.erl create mode 100644 src/emqx_misc.erl create mode 100644 src/emqx_mountpoint.erl create mode 100644 src/emqx_mqtt_caps.erl create mode 100644 src/emqx_mqtt_props.erl create mode 100644 src/emqx_mqueue.erl create mode 100644 src/emqx_node_dump.erl create mode 100644 src/emqx_os_mon.erl create mode 100644 src/emqx_packet.erl create mode 100644 src/emqx_passwd.erl create mode 100644 src/emqx_pd.erl create mode 100644 src/emqx_plugins.erl create mode 100644 src/emqx_pmon.erl create mode 100644 src/emqx_pool.erl create mode 100644 src/emqx_pool_sup.erl create mode 100644 src/emqx_pqueue.erl create mode 100644 src/emqx_psk.erl create mode 100644 src/emqx_reason_codes.erl create mode 100644 src/emqx_router.erl create mode 100644 src/emqx_router_helper.erl create mode 100644 src/emqx_router_sup.erl create mode 100644 src/emqx_rpc.erl create mode 100644 src/emqx_rule_actions_trans.erl create mode 100644 src/emqx_sequence.erl create mode 100644 src/emqx_session.erl create mode 100644 src/emqx_shared_sub.erl create mode 100644 src/emqx_stats.erl create mode 100644 src/emqx_sup.erl create mode 100644 src/emqx_sys.erl create mode 100644 src/emqx_sys_mon.erl create mode 100644 src/emqx_sys_sup.erl create mode 100644 src/emqx_tables.erl create mode 100644 src/emqx_tls_lib.erl create mode 100644 src/emqx_topic.erl create mode 100644 src/emqx_tracer.erl create mode 100644 src/emqx_trie.erl create mode 100644 src/emqx_types.erl create mode 100644 src/emqx_vm.erl create mode 100644 src/emqx_vm_mon.erl create mode 100644 src/emqx_ws_connection.erl create mode 100644 src/emqx_zone.erl create mode 100644 test/emqx_SUITE.erl create mode 100644 test/emqx_SUITE_data/acl.conf create mode 100644 test/emqx_SUITE_data/loaded_modules create mode 100644 test/emqx_SUITE_data/loaded_plugins create mode 100644 test/emqx_access_SUITE_data/acl.conf create mode 100644 test/emqx_access_SUITE_data/acl_deny_action.conf create mode 100644 test/emqx_access_control_SUITE.erl create mode 100644 test/emqx_access_rule_SUITE.erl create mode 100644 test/emqx_acl_cache_SUITE.erl create mode 100644 test/emqx_acl_test_mod.erl create mode 100644 test/emqx_alarm_SUITE.erl create mode 100644 test/emqx_banned_SUITE.erl create mode 100644 test/emqx_batch_SUITE.erl create mode 100644 test/emqx_boot_SUITE.erl create mode 100644 test/emqx_broker_SUITE.erl create mode 100644 test/emqx_broker_helper_SUITE.erl create mode 100644 test/emqx_channel_SUITE.erl create mode 100644 test/emqx_client_SUITE.erl create mode 100644 test/emqx_cm_SUITE.erl create mode 100644 test/emqx_cm_locker_SUITE.erl create mode 100644 test/emqx_cm_registry_SUITE.erl create mode 100644 test/emqx_connection_SUITE.erl create mode 100644 test/emqx_ctl_SUITE.erl create mode 100644 test/emqx_flapping_SUITE.erl create mode 100644 test/emqx_frame_SUITE.erl create mode 100644 test/emqx_gc_SUITE.erl create mode 100644 test/emqx_global_gc_SUITE.erl create mode 100644 test/emqx_guid_SUITE.erl create mode 100644 test/emqx_hooks_SUITE.erl create mode 100644 test/emqx_http_lib_tests.erl create mode 100644 test/emqx_inflight_SUITE.erl create mode 100644 test/emqx_json_SUITE.erl create mode 100644 test/emqx_keepalive_SUITE.erl create mode 100644 test/emqx_limiter_SUITE.erl create mode 100644 test/emqx_listeners_SUITE.erl create mode 100644 test/emqx_logger_SUITE.erl create mode 100644 test/emqx_message_SUITE.erl create mode 100644 test/emqx_metrics_SUITE.erl create mode 100644 test/emqx_misc_SUITE.erl create mode 100644 test/emqx_mountpoint_SUITE.erl create mode 100644 test/emqx_mqtt_SUITE.erl create mode 100644 test/emqx_mqtt_caps_SUITE.erl create mode 100644 test/emqx_mqtt_props_SUITE.erl create mode 100644 test/emqx_mqueue_SUITE.erl create mode 100644 test/emqx_os_mon_SUITE.erl create mode 100644 test/emqx_packet_SUITE.erl create mode 100644 test/emqx_passwd_SUITE.erl create mode 100644 test/emqx_pd_SUITE.erl create mode 100644 test/emqx_plugins_SUITE.erl create mode 100644 test/emqx_plugins_SUITE_data/emqx_mini_plugin/Makefile create mode 100644 test/emqx_plugins_SUITE_data/emqx_mini_plugin/etc/emqx_mini_plugin.conf create mode 100644 test/emqx_plugins_SUITE_data/emqx_mini_plugin/priv/emqx_mini_plugin.schema create mode 100644 test/emqx_plugins_SUITE_data/emqx_mini_plugin/rebar.config create mode 100644 test/emqx_plugins_SUITE_data/emqx_mini_plugin/src/emqx_mini_plugin.app.src create mode 100644 test/emqx_plugins_SUITE_data/emqx_mini_plugin/src/emqx_mini_plugin_app.erl create mode 100644 test/emqx_pmon_SUITE.erl create mode 100644 test/emqx_pool_SUITE.erl create mode 100644 test/emqx_pqueue_SUITE.erl create mode 100644 test/emqx_reason_codes_SUITE.erl create mode 100644 test/emqx_request_handler.erl create mode 100644 test/emqx_request_responser_SUITE.erl create mode 100644 test/emqx_request_sender.erl create mode 100644 test/emqx_router_SUITE.erl create mode 100644 test/emqx_router_helper_SUITE.erl create mode 100644 test/emqx_sequence_SUITE.erl create mode 100644 test/emqx_session_SUITE.erl create mode 100644 test/emqx_shared_sub_SUITE.erl create mode 100644 test/emqx_stats_SUITE.erl create mode 100644 test/emqx_sup_SUITE.erl create mode 100644 test/emqx_sys_SUITE.erl create mode 100644 test/emqx_sys_mon_SUITE.erl create mode 100644 test/emqx_tables_SUITE.erl create mode 100644 test/emqx_takeover_SUITE.erl create mode 100644 test/emqx_tls_lib_tests.erl create mode 100644 test/emqx_topic_SUITE.erl create mode 100644 test/emqx_tracer_SUITE.erl create mode 100644 test/emqx_trie_SUITE.erl create mode 100644 test/emqx_vm_SUITE.erl create mode 100644 test/emqx_vm_mon_SUITE.erl create mode 100644 test/emqx_ws_connection_SUITE.erl create mode 100644 test/emqx_zone_SUITE.erl create mode 100644 test/mqtt_protocol_v5_SUITE.erl create mode 100644 test/props/prop_emqx_base62.erl create mode 100644 test/props/prop_emqx_frame.erl create mode 100644 test/props/prop_emqx_json.erl create mode 100644 test/props/prop_emqx_psk.erl create mode 100644 test/props/prop_emqx_reason_codes.erl create mode 100644 test/props/prop_emqx_rpc.erl create mode 100644 test/props/prop_emqx_sys.erl delete mode 100644 vars-bin.config delete mode 100644 vars-cloud.config delete mode 100644 vars-edge.config delete mode 100644 vars-pkg.config diff --git a/.ci/build_packages/Dockerfile b/.ci/build_packages/Dockerfile new file mode 100644 index 00000000..792acddf --- /dev/null +++ b/.ci/build_packages/Dockerfile @@ -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 diff --git a/.ci/build_packages/tests.sh b/.ci/build_packages/tests.sh new file mode 100644 index 00000000..f7c9d30e --- /dev/null +++ b/.ci/build_packages/tests.sh @@ -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 diff --git a/.ci/docker-compose-file/.env b/.ci/docker-compose-file/.env new file mode 100644 index 00000000..8c9d056c --- /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 00000000..d8294a78 --- /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 00000000..93dfecd2 --- /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 00000000..18e1bb6c --- /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 00000000..61eab91e --- /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 00000000..dee2daff --- /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 00000000..a09bc803 --- /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 00000000..70cc3d24 --- /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 00000000..c4d5bd50 --- /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 00000000..11120964 --- /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 00000000..72aceed6 --- /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 00000000..0b9af451 --- /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 00000000..997388aa --- /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 00000000..78b65594 --- /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 00000000..1cdd2872 --- /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 00000000..7c7f46ce --- /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 00000000..92a3fcf7 --- /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 00000000..814a0f1c --- /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 00000000..a502aeb6 --- /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 00000000..73c219d5 --- /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 00000000..adbb8080 --- /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 00000000..d6ba20ca --- /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 00000000..e4c97325 --- /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 00000000..8b4f9b5a --- /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 00000000..eacbecc3 --- /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 00000000..325c200c --- /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 00000000..6181925d --- /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 00000000..272a5b44 --- /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 00000000..eab60c6f --- /dev/null +++ b/.ci/fvt_tests/http_server/rebar.config @@ -0,0 +1,10 @@ +{erl_opts, [debug_info]}. +{deps, + [ + {minirest, {git, "https://hub.fastgit.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 00000000..f351bb34 --- /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 00000000..b66b7293 --- /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 00000000..85b47bb6 --- /dev/null +++ b/.ci/fvt_tests/relup.lux @@ -0,0 +1,149 @@ +[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 emqx-ubuntu20.04-$(echo $old_vsn | sed -r 's/[v|e]//g')-amd64.zip + ?SH-PROMPT + + !cd emqx + !sed -i 's|listener.wss.external[ \t]*=.*|listener.wss.external = 8085|g' etc/emqx.conf + !sed -i '/emqx_telemetry/d' data/loaded_plugins + !./bin/emqx start + ?EMQ X .* is started successfully! + ?SH-PROMPT + +[shell emqx2] + !cd $PACKAGE_PATH + !cp -f $ONE_MORE_EMQX_PATH/one_more_emqx.sh . + !./one_more_emqx.sh emqx2 + ?SH-PROMPT + !cd emqx2 + + !sed -i '/emqx_telemetry/d' data/loaded_plugins + !./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 600 + ???sent + +[shell emqx] + !cp -f ../emqx-ubuntu20.04-$VSN-amd64.zip releases/ + !./bin/emqx install $VSN + ?SH-PROMPT + !./bin/emqx versions |grep permanent | grep -oE "[0-9].[0-9].[0-9]" + ?$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 + +[shell emqx2] + !cp -f ../emqx-ubuntu20.04-$VSN-amd64.zip releases/ + !./bin/emqx install $VSN + ?SH-PROMPT + !./bin/emqx versions |grep permanent | grep -oE "[0-9].[0-9].[0-9]" + ?$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 + +[shell bench] + ???publish complete + ??SH-PROMPT: + !curl http://127.0.0.1:8080/counter + ???{"data":600,"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 00000000..c563aa10 --- /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 00000000..4ed73da9 --- /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 00000000..f28160c5 --- /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 00000000..0258866d --- /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: tigercl + +--- + + + + +**Environment**: + +- EMQ X version (e.g. `emqx_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 00000000..67b1dfa8 --- /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: tigercl + +--- + + + +**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 00000000..80b49407 --- /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: tigercl + +--- + +**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 00000000..a578e897 --- /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://hub.fastgit.org/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 00000000..7197467d --- /dev/null +++ b/.github/weekly-digest.yml @@ -0,0 +1,7 @@ +# Configuration for weekly-digest - https://hub.fastgit.org/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 00000000..bf89ba25 --- /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/apps_version_check.yaml b/.github/workflows/apps_version_check.yaml new file mode 100644 index 00000000..4975e5c1 --- /dev/null +++ b/.github/workflows/apps_version_check.yaml @@ -0,0 +1,12 @@ +name: Check Apps Version + +on: [pull_request] + +jobs: + check_apps_version: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v1 + - name: Check apps version + run: ./scripts/apps-version-check.sh diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml new file mode 100644 index 00000000..d9a79aa3 --- /dev/null +++ b/.github/workflows/build_packages.yaml @@ -0,0 +1,480 @@ +name: Cross build packages + +on: + schedule: + - cron: '0 */6 * * *' + push: + tags: + - v* + - e* + release: + types: + - published + workflow_dispatch: + +jobs: + prepare: + runs-on: ubuntu-20.04 + container: emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04 + + outputs: + profiles: ${{ steps.set_profile.outputs.profiles}} + + steps: + - uses: actions/checkout@v2 + with: + path: source + - name: set profile + id: set_profile + shell: bash + run: | + if make -C source emqx-ee --dry-run > /dev/null 2>&1; then + echo "::set-output name=profiles::[\"emqx-ee\"]" + else + echo "::set-output name=profiles::[\"emqx\", \"emqx-edge\"]" + fi + - name: get_all_deps + if: endsWith(github.repository, 'emqx') + run: | + make -C source deps-all + zip -ryq source.zip source + - name: get_all_deps + if: endsWith(github.repository, 'enterprise') + run: | + echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org" > $HOME/.git-credentials + git config --global credential.helper store + echo "${{ secrets.CI_GIT_TOKEN }}" >> source/scripts/git-token + make -C source deps-all + zip -ryq source.zip source + - uses: actions/upload-artifact@v2 + with: + name: source + path: source.zip + + windows: + runs-on: windows-2019 + + needs: prepare + if: endsWith(github.repository, 'emqx') + + strategy: + matrix: + profile: ${{fromJSON(needs.prepare.outputs.profiles)}} + exclude: + - profile: emqx-edge + + steps: + - uses: actions/download-artifact@v2 + with: + name: source + path: . + - name: unzip source code + run: Expand-Archive -Path source.zip -DestinationPath ./ + - uses: ilammy/msvc-dev-cmd@v1 + - uses: gleam-lang/setup-erlang@v1.1.0 + id: install_erlang + with: + otp-version: 23.2 + - name: build + env: + PYTHON: python + run: | + $env:PATH = "${{ steps.install_erlang.outputs.erlpath }}\bin;$env:PATH" + + $version = $( "${{ github.ref }}" -replace "^(.*)/(.*)/" ) + if ($version -match "^v[0-9]+\.[0-9]+(\.[0-9]+)?") { + $regex = "[0-9]+\.[0-9]+(-alpha|-beta|-rc)?\.[0-9]+" + $pkg_name = "${{ matrix.profile }}-windows-$([regex]::matches($version, $regex).value).zip" + } + else { + $pkg_name = "${{ matrix.profile }}-windows-$($version -replace '/').zip" + } + cd source + ## We do not build/release bcrypt for windows package + Remove-Item -Recurse -Force -Path _build/default/lib/bcrypt/ + if (Test-Path rebar.lock) { + Remove-Item -Force -Path rebar.lock + } + make ${{ matrix.profile }} + mkdir -p _packages/${{ matrix.profile }} + Compress-Archive -Path _build/${{ matrix.profile }}/rel/emqx -DestinationPath _build/${{ matrix.profile }}/rel/$pkg_name + mv _build/${{ matrix.profile }}/rel/$pkg_name _packages/${{ matrix.profile }} + Get-FileHash -Path "_packages/${{ matrix.profile }}/$pkg_name" | Format-List | grep 'Hash' | awk '{print $3}' > _packages/${{ matrix.profile }}/$pkg_name.sha256 + - name: run emqx + timeout-minutes: 1 + run: | + cd source + ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx start + Start-Sleep -s 5 + ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx stop + ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx install + ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx uninstall + - uses: actions/upload-artifact@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + name: ${{ matrix.profile }} + path: source/_packages/${{ matrix.profile }}/. + + mac: + runs-on: macos-10.15 + + needs: prepare + + strategy: + matrix: + profile: ${{fromJSON(needs.prepare.outputs.profiles)}} + erl_otp: + - 23.2.7.2 + exclude: + - profile: emqx-edge + + steps: + - uses: actions/download-artifact@v2 + with: + name: source + path: . + - name: unzip source code + run: unzip -q source.zip + - 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 + run: | + 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 -C source ${{ matrix.profile }}-zip + - name: test + run: | + cd source + pkg_name=$(basename _packages/${{ matrix.profile }}/${{ matrix.profile }}-*.zip) + unzip -q _packages/${{ matrix.profile }}/$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 + openssl dgst -sha256 ./_packages/${{ matrix.profile }}/$pkg_name | awk '{print $2}' > ./_packages/${{ matrix.profile }}/$pkg_name.sha256 + - uses: actions/upload-artifact@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + name: ${{ matrix.profile }} + path: source/_packages/${{ matrix.profile }}/. + + linux: + runs-on: ubuntu-20.04 + + needs: prepare + + strategy: + matrix: + profile: ${{fromJSON(needs.prepare.outputs.profiles)}} + arch: + - amd64 + - arm64 + os: + - ubuntu20.04 + - ubuntu18.04 + - ubuntu16.04 + - debian10 + - debian9 + # - opensuse + - centos8 + - centos7 + - centos6 + - raspbian10 + - raspbian9 + exclude: + - os: centos6 + arch: arm64 + - os: raspbian9 + arch: amd64 + - os: raspbian10 + arch: amd64 + - os: raspbian9 + profile: emqx + - os: raspbian10 + profile: emqx + - os: raspbian9 + profile: emqx-ee + - os: raspbian10 + profile: emqx-ee + + defaults: + run: + shell: bash + + steps: + - name: prepare docker + run: | + mkdir -p $HOME/.docker + echo '{ "experimental": "enabled" }' | tee $HOME/.docker/config.json + echo '{ "experimental": true, "storage-driver": "overlay2", "max-concurrent-downloads": 50, "max-concurrent-uploads": 50}' | sudo tee /etc/docker/daemon.json + sudo systemctl restart docker + docker info + docker buildx create --use --name mybuild + docker run --rm --privileged tonistiigi/binfmt --install all + - uses: actions/download-artifact@v2 + with: + name: source + path: . + - name: unzip source code + run: unzip -q source.zip + - name: downloads emqx zip packages + env: + PROFILE: ${{ matrix.profile }} + ARCH: ${{ matrix.arch }} + SYSTEM: ${{ matrix.os }} + run: | + set -e -u -x + cd source + if [ $PROFILE = "emqx" ];then broker="emqx-ce"; else broker="$PROFILE"; fi + if [ $PROFILE = "emqx-ee" ];then edition='enterprise'; else edition='opensource'; fi + + vsn="$(./pkg-vsn.sh)" + pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')" + if [ $PROFILE = "emqx-ee" ]; then + old_vsns=($(git tag -l "e$pre_vsn.[0-9]" | sed "s/e$vsn//")) + else + old_vsns=($(git tag -l "v$pre_vsn.[0-9]" | sed "s/v$vsn//")) + fi + + mkdir -p _upgrade_base + cd _upgrade_base + for tag in ${old_vsns[@]};do + if [ ! -z "$(echo $(curl -I -m 10 -o /dev/null -s -w %{http_code} https://s3-${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/${{ secrets.AWS_S3_BUCKET }}/$broker/$tag/$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip) | grep -oE "^[23]+")" ];then + wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$broker/$tag/$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip + wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$broker/$tag/$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip.sha256 + echo "$(cat $PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip.sha256) $PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip" | sha256sum -c || exit 1 + fi + done + cd - + - name: build emqx packages + env: + ERL_OTP: erl23.2.7.2-emqx-2 + PROFILE: ${{ matrix.profile }} + ARCH: ${{ matrix.arch }} + SYSTEM: ${{ matrix.os }} + run: | + set -e -u + cd source + docker buildx build --no-cache \ + --platform=linux/$ARCH \ + -t cross_build_emqx_for_$SYSTEM \ + -f .ci/build_packages/Dockerfile \ + --build-arg BUILD_FROM=emqx/build-env:$ERL_OTP-$SYSTEM \ + --build-arg EMQX_NAME=$PROFILE \ + --output type=tar,dest=/tmp/cross-build-$PROFILE-for-$SYSTEM.tar . + + mkdir -p /tmp/packages/$PROFILE + tar -xvf /tmp/cross-build-$PROFILE-for-$SYSTEM.tar --wildcards emqx/_packages/$PROFILE/* + mv emqx/_packages/$PROFILE/* /tmp/packages/$PROFILE/ + rm -rf /tmp/cross-build-$PROFILE-for-$SYSTEM.tar + + docker rm -f $(docker ps -a -q) + docker volume prune -f + - name: create sha256 + env: + PROFILE: ${{ matrix.profile}} + run: | + if [ -d /tmp/packages/$PROFILE ]; then + cd /tmp/packages/$PROFILE + for var in $(ls emqx-* ); do + bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256" + done + cd - + fi + - uses: actions/upload-artifact@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + name: ${{ matrix.profile }} + path: /tmp/packages/${{ matrix.profile }}/. + + docker: + runs-on: ubuntu-20.04 + + needs: prepare + + strategy: + matrix: + profile: ${{fromJSON(needs.prepare.outputs.profiles)}} + arch: + - [amd64, x86_64] + - [arm64v8, aarch64] + - [arm32v7, arm] + - [i386, i386] + - [s390x, s390x] + exclude: + - profile: emqx-ee + arch: [i386, i386] + - profile: emqx-ee + arch: [s390x, s390x] + + steps: + - uses: actions/download-artifact@v2 + with: + name: source + path: . + - name: unzip source code + run: unzip -q source.zip + - name: build emqx docker image + env: + PROFILE: ${{ matrix.profile }} + ARCH: ${{ matrix.arch[0] }} + QEMU_ARCH: ${{ matrix.arch[1] }} + run: | + sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + + cd source + sudo TARGET=emqx/$PROFILE ARCH=$ARCH QEMU_ARCH=$QEMU_ARCH make docker + cd _packages/$PROFILE && for var in $(ls ${PROFILE}-docker-* ); do sudo bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd - + - uses: actions/upload-artifact@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + name: ${{ matrix.profile }} + path: source/_packages/${{ matrix.profile }}/. + + delete-artifact: + runs-on: ubuntu-20.04 + needs: [prepare, mac, linux, docker] + steps: + - uses: geekyeggo/delete-artifact@v1 + with: + name: source + + upload: + runs-on: ubuntu-20.04 + + if: startsWith(github.ref, 'refs/tags/') + + needs: [prepare, mac, linux, docker] + + strategy: + matrix: + profile: ${{fromJSON(needs.prepare.outputs.profiles)}} + + steps: + - uses: actions/checkout@v2 + - name: get_version + run: | + echo 'version<> $GITHUB_ENV + echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + - uses: actions/download-artifact@v2 + with: + name: ${{ matrix.profile }} + path: ./_packages/${{ matrix.profile }} + - name: install dos2unix + run: sudo apt-get update && sudo apt install -y dos2unix + - name: get packages + run: | + set -e -u + cd _packages/${{ matrix.profile }} + for var in $( ls |grep emqx |grep -v sha256); do + dos2unix $var.sha256 + echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1 + done + cd - + - name: upload aws s3 + run: | + set -e -u + if [ "${{ matrix.profile }}" == "emqx" ];then + broker="emqx-ce" + else + broker=${{ matrix.profile }} + fi + aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} + aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws configure set default.region ${{ secrets.AWS_DEFAULT_REGION }} + + aws s3 cp --recursive _packages/${{ matrix.profile }} s3://${{ secrets.AWS_S3_BUCKET }}/$broker/${{ env.version }} + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$broker/${{ env.version }}/*" + - uses: Rory-Z/upload-release-asset@v1 + if: github.event_name == 'release' && matrix.profile != 'emqx-ee' + with: + repo: emqx + path: "_packages/${{ matrix.profile }}/emqx-*" + token: ${{ github.token }} + - uses: Rory-Z/upload-release-asset@v1 + if: github.event_name == 'release' && matrix.profile == 'emqx-ee' + with: + repo: emqx-enterprise + path: "_packages/${{ matrix.profile }}/emqx-*" + token: ${{ github.token }} + - name: update to emqx.io + if: github.event_name == 'release' + run: | + set -e -x -u + curl -w %{http_code} \ + --insecure \ + -H "Content-Type: application/json" \ + -H "token: ${{ secrets.EMQX_IO_TOKEN }}" \ + -X POST \ + -d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ env.version }}\" }" \ + ${{ secrets.EMQX_IO_RELEASE_API }} + - name: push docker image to docker hub + if: github.event_name == 'release' + run: | + set -e -x -u + sudo make docker-prepare + cd _packages/${{ matrix.profile }} && for var in $(ls |grep docker |grep -v sha256); do unzip $var; sudo docker load < ${var%.*}; rm -f ${var%.*}; done && cd - + echo ${{ secrets.DOCKER_HUB_TOKEN }} |sudo docker login -u ${{ secrets.DOCKER_HUB_USER }} --password-stdin + sudo TARGET=emqx/${{ matrix.profile }} make docker-push + sudo TARGET=emqx/${{ matrix.profile }} make docker-manifest-list + - name: update repo.emqx.io + if: github.event_name == 'release' && endsWith(github.repository, 'enterprise') && matrix.profile == 'emqx-ee' + run: | + curl --silent --show-error \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -X POST \ + -d "{\"ref\":\"v1.0.1\",\"inputs\":{\"version\": \"${{ env.version }}\", \"emqx_ee\": \"true\"}}" \ + "https://api.hub.fastgit.org/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_repos.yaml/dispatches" + - name: update repo.emqx.io + if: github.event_name == 'release' && endsWith(github.repository, 'emqx') && matrix.profile == 'emqx' + run: | + curl --silent --show-error \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -X POST \ + -d "{\"ref\":\"v1.0.1\",\"inputs\":{\"version\": \"${{ env.version }}\", \"emqx_ce\": \"true\"}}" \ + "https://api.hub.fastgit.org/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_repos.yaml/dispatches" + - name: update homebrew packages + if: github.event_name == 'release' && endsWith(github.repository, 'emqx') && matrix.profile == 'emqx' + run: | + if [ -z $(echo $version | grep -oE "(alpha|beta|rc)\.[0-9]") ]; then + curl --silent --show-error \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -X POST \ + -d "{\"ref\":\"v1.0.1\",\"inputs\":{\"version\": \"${{ env.version }}\"}}" \ + "https://api.hub.fastgit.org/repos/emqx/emqx-ci-helper/actions/workflows/update_emqx_homebrew.yaml/dispatches" + fi + - uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ matrix.profile }} diff --git a/.github/workflows/build_slim_packages.yaml b/.github/workflows/build_slim_packages.yaml new file mode 100644 index 00000000..4add80a0 --- /dev/null +++ b/.github/workflows/build_slim_packages.yaml @@ -0,0 +1,116 @@ +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 }}@hub.fastgit.org" > $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 + - 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 + + 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 }}@hub.fastgit.org" > $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 + run: | + 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 ${EMQX_NAME}-zip + - 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/check_deps_integrity.yaml b/.github/workflows/check_deps_integrity.yaml new file mode 100644 index 00000000..0aa8f790 --- /dev/null +++ b/.github/workflows/check_deps_integrity.yaml @@ -0,0 +1,13 @@ +name: Check Rebar Dependencies + +on: [pull_request] + +jobs: + check_deps_integrity: + runs-on: ubuntu-20.04 + container: emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04 + + steps: + - uses: actions/checkout@v2 + - name: Run check-deps-integrity.escript + run: ./scripts/check-deps-integrity.escript diff --git a/.github/workflows/elvis_lint.yaml b/.github/workflows/elvis_lint.yaml new file mode 100644 index 00000000..4cd4fa9e --- /dev/null +++ b/.github/workflows/elvis_lint.yaml @@ -0,0 +1,16 @@ +name: Elvis Linter + +on: [pull_request] + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Set git token + if: endsWith(github.repository, 'enterprise') + run: | + echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org" > $HOME/.git-credentials + git config --global credential.helper store + - run: | + ./scripts/elvis-check.sh $GITHUB_BASE_REF diff --git a/.github/workflows/git_sync.yaml b/.github/workflows/git_sync.yaml new file mode 100644 index 00000000..34322976 --- /dev/null +++ b/.github/workflows/git_sync.yaml @@ -0,0 +1,42 @@ +name: Sync to enterprise + +on: + push: + branches: + - master + +jobs: + sync_to_enterprise: + runs-on: ubuntu-20.04 + if: github.repository == 'emqx/emqx' + steps: + - name: git-sync + uses: Rory-Z/git-sync@v3.0.1 + with: + source_repo: ${{ github.repository }} + source_branch: ${{ github.ref }} + destination_repo: "${{ github.repository_owner }}/emqx-enterprise" + destination_branch: ${{ github.ref }} + destination_ssh_private_key: "${{ secrets.CI_SSH_PRIVATE_KEY }}" + - name: create pull request + id: create_pull_request + run: | + set -euo pipefail + R=$(curl --silent --show-error \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -X POST \ + -d '{"title": "Sync code into enterprise from opensource", "head": "master", "base":"enterprise"}' \ + https://api.hub.fastgit.org/repos/${{ github.repository_owner }}/emqx-enterprise/pulls) + echo $R | jq + echo "::set-output name=url::$(echo $R | jq '.url')" + - name: request reviewers for a pull request + if: steps.create_pull_request.outputs.url != 'null' + run: | + set -euo pipefail + curl --silent --show-error \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \ + -X POST \ + -d '{"team_reviewers":["emqx-devs"]}' \ + ${{ steps.create_pull_request.outputs.url }}/requested_reviewers diff --git a/.github/workflows/gitee-repos-mirror.yml b/.github/workflows/gitee-repos-mirror.yml deleted file mode 100644 index d5594910..00000000 --- a/.github/workflows/gitee-repos-mirror.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Gitee repos mirror periodic job - -on: - push: - watch: - types: started - schedule: - - cron: "0 23 * * *" - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - - name: Mirror the Github organization repos to Gitee. - 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: 600 - debug: true - force_update: true - black_list: "dgiot.github.io, issue-generator, dgiot_amazedtu" \ No newline at end of file diff --git a/.github/workflows/run_cts_tests.yaml b/.github/workflows/run_cts_tests.yaml new file mode 100644 index 00000000..cc715b35 --- /dev/null +++ b/.github/workflows/run_cts_tests.yaml @@ -0,0 +1,406 @@ +name: Compatibility Test Suite + +on: + push: + tags: + - v* + - e* + release: + types: + - published + pull_request: + +jobs: + ldap: + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + ldap_tag: + - 2.4.50 + network_type: + - ipv4 + - ipv6 + + steps: + - uses: actions/checkout@v1 + - name: docker compose up + env: + LDAP_TAG: ${{ matrix.ldap_tag }} + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-ldap-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build + - name: setup + if: matrix.network_type == 'ipv4' + run: | + echo EMQX_AUTH__LDAP__SERVERS=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ldap) >> "$GITHUB_ENV" + - name: setup + if: matrix.network_type == 'ipv6' + run: | + echo EMQX_AUTH__LDAP__SERVERS=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' ldap) >> "$GITHUB_ENV" + - name: set git token + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + docker exec -i erlang bash -c "echo \"https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org\" > /root/.git-credentials && git config --global credential.helper store" + fi + - name: run test cases + run: | + export CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ + printenv > .env + docker exec -i erlang sh -c "make ensure-rebar3" + docker exec -i erlang sh -c "./rebar3 eunit --dir apps/emqx_auth_ldap" + docker exec --env-file .env -i erlang sh -c "./rebar3 ct --dir apps/emqx_auth_ldap" + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: logs_ldap${{ matrix.ldap_tag }}_${{ matrix.network_type }} + path: _build/test/logs + + mongo: + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + mongo_tag: + - 3 + - 4 + network_type: + - ipv4 + - ipv6 + connect_type: + - tls + - tcp + + steps: + - uses: actions/checkout@v1 + - name: docker-compose up + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-mongo-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build + - name: setup + env: + MONGO_TAG: ${{ matrix.mongo_tag }} + if: matrix.connect_type == 'tls' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__MONGO__SSL=on + EMQX_AUTH__MONGO__SSL__CACERTFILE=/emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/ca.pem + EMQX_AUTH__MONGO__SSL__CERTFILE=/emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/client-cert.pem + EMQX_AUTH__MONGO__SSL__KEYFILE=/emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/client-key.pem + EMQX_AUTH__MONGO__SSL__VERIFY=true + EMQX_AUTH__MONGO__SSL__SERVER_NAME_INDICATION=disable + EOF + - name: setup + env: + MONGO_TAG: ${{ matrix.mongo_tag }} + if: matrix.connect_type == 'tcp' + run: | + echo EMQX_AUTH__MONGO__SSL=off >> "$GITHUB_ENV" + - name: setup + if: matrix.network_type == 'ipv4' + run: | + echo "EMQX_AUTH__MONGO__SERVER=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mongo):27017" >> "$GITHUB_ENV" + - name: setup + if: matrix.network_type == 'ipv6' + run: | + echo "EMQX_AUTH__MONGO__SERVER=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' mongo):27017" >> "$GITHUB_ENV" + - name: set git token + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + docker exec -i erlang bash -c "echo \"https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org\" > /root/.git-credentials && git config --global credential.helper store" + fi + - name: run test cases + run: | + export CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ + printenv > .env + docker exec -i erlang sh -c "make ensure-rebar3" + docker exec -i erlang sh -c "./rebar3 eunit --dir apps/emqx_auth_mongo" + docker exec --env-file .env -i erlang sh -c "./rebar3 ct --dir apps/emqx_auth_mongo" + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: logs_mongo${{ matrix.mongo_tag }}_${{ matrix.network_type }}_${{ matrix.connect_type }} + path: _build/test/logs + + mysql: + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + mysql_tag: + - 5.7 + - 8 + network_type: + - ipv4 + - ipv6 + connect_type: + - tls + - tcp + + steps: + - uses: actions/checkout@v1 + - name: docker-compose up + timeout-minutes: 5 + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-mysql-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build + while [ $(docker ps -a --filter name=client --filter exited=0 | wc -l) \ + != $(docker ps -a --filter name=client | wc -l) ]; do + sleep 5 + done + - name: setup + env: + MYSQL_TAG: ${{ matrix.mysql_tag }} + if: matrix.connect_type == 'tls' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__MYSQL__USERNAME=ssluser + EMQX_AUTH__MYSQL__PASSWORD=public + EMQX_AUTH__MYSQL__DATABASE=mqtt + EMQX_AUTH__MYSQL__SSL=on + EMQX_AUTH__MYSQL__SSL__CACERTFILE=/emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/ca.pem + EMQX_AUTH__MYSQL__SSL__CERTFILE=/emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-cert.pem + EMQX_AUTH__MYSQL__SSL__KEYFILE=/emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-key.pem + EMQX_AUTH__MYSQL__SSL__VERIFY=true + EMQX_AUTH__MYSQL__SSL__SERVER_NAME_INDICATION=disable + EOF + - name: setup + env: + MYSQL_TAG: ${{ matrix.mysql_tag }} + if: matrix.connect_type == 'tcp' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__MYSQL__USERNAME=root + EMQX_AUTH__MYSQL__PASSWORD=public + EMQX_AUTH__MYSQL__DATABASE=mqtt + EMQX_AUTH__MYSQL__SSL=off + EOF + - name: setup + if: matrix.network_type == 'ipv4' + run: | + echo "EMQX_AUTH__MYSQL__SERVER=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql):3306" >> "$GITHUB_ENV" + - name: setup + if: matrix.network_type == 'ipv6' + run: | + echo "EMQX_AUTH__MYSQL__SERVER=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' mysql):3306" >> "$GITHUB_ENV" + - name: set git token + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + docker exec -i erlang bash -c "echo \"https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org\" > /root/.git-credentials && git config --global credential.helper store" + fi + - name: run test cases + run: | + export CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ + printenv > .env + docker exec -i erlang sh -c "make ensure-rebar3" + docker exec -i erlang sh -c "./rebar3 eunit --dir apps/emqx_auth_mysql" + docker exec --env-file .env -i erlang sh -c "./rebar3 ct --dir apps/emqx_auth_mysql" + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: logs_mysql${{ matrix.mysql_tag }}_${{ matrix.network_type }}_${{ matrix.connect_type }} + path: _build/test/logs + + pgsql: + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + pgsql_tag: + - 9 + - 10 + - 11 + - 12 + - 13 + network_type: + - ipv4 + - ipv6 + connect_type: + - tls + - tcp + steps: + - uses: actions/checkout@v1 + - name: docker-compose up + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-pgsql-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build + - name: setup + env: + PGSQL_TAG: ${{ matrix.pgsql_tag }} + if: matrix.connect_type == 'tls' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__PGSQL__SSL=on + EMQX_AUTH__PGSQL__SSL__CACERTFILE=/emqx/apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/ca.pem + EMQX_AUTH__PGSQL__SSL__CERTFILE=/emqx/apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/client-cert.pem + EMQX_AUTH__PGSQL__SSL__KEYFILE=/emqx/apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/client-key.pem + EMQX_AUTH__PGSQL__SSL__VERIFY=true + EMQX_AUTH__PGSQL__SSL__SERVER_NAME_INDICATION=disable + EOF + - name: setup + env: + PGSQL_TAG: ${{ matrix.pgsql_tag }} + if: matrix.connect_type == 'tcp' + run: | + echo EMQX_AUTH__PGSQL__SSL=off >> "$GITHUB_ENV" + - name: setup + if: matrix.network_type == 'ipv4' + run: | + echo "EMQX_AUTH__PGSQL__SERVER=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgsql):5432" >> "$GITHUB_ENV" + - name: setup + if: matrix.network_type == 'ipv6' + run: | + echo "EMQX_AUTH__PGSQL__SERVER=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' pgsql):5432" >> "$GITHUB_ENV" + - name: set git token + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + docker exec -i erlang bash -c "echo \"https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org\" > /root/.git-credentials && git config --global credential.helper store" + fi + - name: run test cases + run: | + export EMQX_AUTH__PGSQL__USERNAME=root \ + EMQX_AUTH__PGSQL__PASSWORD=public \ + EMQX_AUTH__PGSQL__DATABASE=mqtt \ + CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ + printenv > .env + docker exec -i erlang sh -c "make ensure-rebar3" + docker exec -i erlang sh -c "./rebar3 eunit --dir apps/emqx_auth_pgsql" + docker exec --env-file .env -i erlang sh -c "./rebar3 ct --dir apps/emqx_auth_pgsql" + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: logs_pgsql${{ matrix.pgsql_tag }}_${{ matrix.network_type }}_${{ matrix.connect_type }} + path: _build/test/logs + + redis: + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + redis_tag: + - 5 + - 6 + network_type: + - ipv4 + - ipv6 + connect_type: + - tls + - tcp + node_type: + - single + - sentinel + - cluster + exclude: + - redis_tag: 5 + connect_type: tls + + steps: + - uses: actions/checkout@v1 + - name: docker-compose up + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-redis-${{ matrix.node_type }}-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build + - name: setup + env: + REDIS_TAG: ${{ matrix.redis_tag }} + if: matrix.connect_type == 'tls' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__REDIS__SSL=on + EMQX_AUTH__REDIS__SSL__CACERTFILE=/emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/ca.crt + EMQX_AUTH__REDIS__SSL__CERTFILE=/emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/redis.crt + EMQX_AUTH__REDIS__SSL__KEYFILE=/emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/redis.key + EMQX_AUTH__REDIS__SSL__VERIFY=true + EMQX_AUTH__REDIS__SSL__SERVER_NAME_INDICATION=disable + EOF + - name: setup + env: + REDIS_TAG: ${{ matrix.redis_tag }} + if: matrix.connect_type == 'tcp' + run: | + echo EMQX_AUTH__REDIS__SSL=off >> "$GITHUB_ENV" + - name: get server address + run: | + ipv4_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' redis) + ipv6_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' redis) + cat <<-EOF >> "$GITHUB_ENV" + redis_ipv4_address=$ipv4_address + redis_ipv6_address=$ipv6_address + EOF + - name: setup + if: matrix.node_type == 'single' && matrix.connect_type == 'tcp' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__REDIS__TYPE=single + EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:6379 + EOF + - name: setup + if: matrix.node_type == 'single' && matrix.connect_type == 'tls' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__REDIS__TYPE=single + EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:6380 + EOF + - name: setup + if: matrix.node_type == 'sentinel' && matrix.connect_type == 'tcp' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__REDIS__TYPE=sentinel + EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:26379 + EMQX_AUTH__REDIS__SENTINEL=mymaster + EOF + - name: setup + if: matrix.node_type == 'sentinel' && matrix.connect_type == 'tls' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__REDIS__TYPE=sentinel + EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:26380 + EMQX_AUTH__REDIS__SENTINEL=mymaster + EOF + - name: setup + if: matrix.node_type == 'cluster' && matrix.connect_type == 'tcp' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__REDIS__TYPE=cluster + EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:7000 + EOF + - name: setup + if: matrix.node_type == 'cluster' && matrix.connect_type == 'tls' + run: | + cat <<-EOF >> "$GITHUB_ENV" + EMQX_AUTH__REDIS__TYPE=cluster + EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:8000 + EOF + - name: set git token + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + docker exec -i erlang bash -c "echo \"https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org\" > /root/.git-credentials && git config --global credential.helper store" + fi + - name: run test cases + run: | + export CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ + export EMQX_AUTH__REIDS__PASSWORD=public + printenv > .env + docker exec -i erlang sh -c "make ensure-rebar3" + docker exec -i erlang sh -c "./rebar3 eunit --dir apps/emqx_auth_redis" + docker exec --env-file .env -i erlang sh -c "./rebar3 ct --dir apps/emqx_auth_redis" + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: logs_redis${{ matrix.redis_tag }}_${{ matrix.node_type }}_${{ matrix.network_type }}_${{ matrix.connect_type }} + path: _build/test/logs diff --git a/.github/workflows/run_fvt_tests.yaml b/.github/workflows/run_fvt_tests.yaml new file mode 100644 index 00000000..c4f7b246 --- /dev/null +++ b/.github/workflows/run_fvt_tests.yaml @@ -0,0 +1,273 @@ +name: Functional Verification Tests + +on: + push: + tags: + - v* + - e* + release: + types: + - published + pull_request: + +jobs: + docker_test: + runs-on: ubuntu-20.04 + + 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 }}@hub.fastgit.org" > $HOME/.git-credentials + git config --global credential.helper store + echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token + make deps-emqx-ee + echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV + echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV + else + echo "TARGET=emqx/emqx" >> $GITHUB_ENV + echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV + fi + - name: make emqx image + run: make docker + - name: run emqx + timeout-minutes: 5 + run: | + set -e -u -x + echo "CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_" >> .ci/docker-compose-file/conf.cluster.env + echo "EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s" >> .ci/docker-compose-file/conf.cluster.env + echo "EMQX_MQTT__MAX_TOPIC_ALIAS=10" >> .ci/docker-compose-file/conf.cluster.env + docker-compose \ + -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \ + -f .ci/docker-compose-file/docker-compose-python.yaml \ + up -d + while ! docker exec -i node1.emqx.io bash -c "emqx eval \"['emqx@node1.emqx.io','emqx@node2.emqx.io'] = maps:get(running_nodes, ekka_cluster:info()).\"" > /dev/null 2>&1; do + echo "['$(date -u +"%Y-%m-%dT%H:%M:%SZ")']:waiting emqx"; + sleep 5; + done + - name: verify EMQX_LOADED_PLUGINS override working + run: | + expected="{emqx_sn, true}." + output=$(docker exec -i node1.emqx.io bash -c "cat data/loaded_plugins" | tail -n1) + if [ "$expected" != "$output" ]; then + exit 1 + fi + - name: make paho tests + run: | + if ! docker exec -i python /scripts/pytest.sh; then + docker logs node1.emqx.io + docker logs node2.emqx.io + exit 1 + fi + + helm_test: + runs-on: ubuntu-20.04 + + 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 }}@hub.fastgit.org" > $HOME/.git-credentials + git config --global credential.helper store + echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token + make deps-emqx-ee + echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV + else + echo "TARGET=emqx/emqx" >> $GITHUB_ENV + fi + - name: make emqx image + run: make docker + - name: install k3s + env: + KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" + run: | + sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts" + curl -sfL https://get.k3s.io | sh - + sudo chmod 644 /etc/rancher/k3s/k3s.yaml + kubectl cluster-info + - name: install helm + env: + KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" + run: | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 + sudo chmod 700 get_helm.sh + sudo ./get_helm.sh + helm version + - name: run emqx on chart + env: + KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" + timeout-minutes: 5 + run: | + version=$(./pkg-vsn.sh) + sudo docker save ${TARGET}:$version -o emqx.tar.gz + sudo k3s ctr image import emqx.tar.gz + + sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/charts/emqx/Chart.yaml + sed -i '/emqx_telemetry/d' deploy/charts/emqx/values.yaml + + helm install emqx \ + --set image.repository=${TARGET} \ + --set image.pullPolicy=Never \ + --set emqxAclConfig="" \ + --set image.pullPolicy=Never \ + --set emqxConfig.EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s \ + --set emqxConfig.EMQX_MQTT__MAX_TOPIC_ALIAS=10 \ + deploy/charts/emqx \ + --debug + + while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \ + != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do + echo "=============================="; + kubectl get pods; + echo "=============================="; + echo "waiting emqx started"; + sleep 10; + done + - name: get pods log + if: failure() + env: + KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" + run: kubectl describe pods emqx-0 + - uses: actions/checkout@v2 + with: + repository: emqx/paho.mqtt.testing + ref: develop-4.0 + path: paho.mqtt.testing + - name: install pytest + run: | + pip install pytest + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: run paho test + env: + KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" + run: | + emqx_svc=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}") + emqx1=$(kubectl get pods emqx-1 -o jsonpath='{.status.podIP}') + emqx2=$(kubectl get pods emqx-2 -o jsonpath='{.status.podIP}') + + pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host $emqx_svc + RESULT=$? + pytest -v paho.mqtt.testing/interoperability/test_cluster --host1 $emqx1 --host2 $emqx2 + RESULT=$((RESULT + $?)) + if [ 0 -ne $RESULT ]; then + kubectl logs emqx-1 + kubectl logs emqx-2 + fi + exit $RESULT + + relup_test: + runs-on: ubuntu-20.04 + container: emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04 + defaults: + run: + shell: bash + steps: + - uses: actions/setup-python@v2 + with: + python-version: '3.8' + architecture: 'x64' + - uses: actions/checkout@v2 + with: + repository: emqx/paho.mqtt.testing + ref: develop-4.0 + path: paho.mqtt.testing + - uses: actions/checkout@v2 + with: + repository: terry-xiaoyu/one_more_emqx + ref: master + path: one_more_emqx + - uses: actions/checkout@v2 + with: + repository: emqx/emqtt-bench + ref: master + path: emqtt-bench + - uses: actions/checkout@v2 + with: + repository: hawk/lux + ref: lux-2.4 + path: lux + - uses: actions/checkout@v2 + with: + repository: ${{ github.repository }} + path: emqx + fetch-depth: 0 + - name: prepare + run: | + if make -C emqx emqx-ee --dry-run > /dev/null 2>&1; then + echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org" > $HOME/.git-credentials + git config --global credential.helper store + echo "${{ secrets.CI_GIT_TOKEN }}" >> emqx/scripts/git-token + echo "PROFILE=emqx-ee" >> $GITHUB_ENV + else + echo "PROFILE=emqx" >> $GITHUB_ENV + fi + - name: get version + run: | + set -e -x -u + cd emqx + if [ $PROFILE = "emqx" ];then + broker="emqx-ce" + edition='opensource' + else + broker="emqx-ee" + edition='enterprise' + fi + echo "BROKER=$broker" >> $GITHUB_ENV + + vsn="$(./pkg-vsn.sh)" + echo "VSN=$vsn" >> $GITHUB_ENV + + pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')" + if [ $PROFILE = "emqx" ]; then + old_vsns="$(git tag -l "v$pre_vsn.[0-9]" | xargs echo -n | sed "s/v$vsn//")" + else + old_vsns="$(git tag -l "e$pre_vsn.[0-9]" | xargs echo -n | sed "s/e$vsn//")" + fi + echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV + - name: download emqx + run: | + set -e -x -u + mkdir -p emqx/_upgrade_base + cd emqx/_upgrade_base + old_vsns=($(echo $OLD_VSNS | tr ' ' ' ')) + for old_vsn in ${old_vsns[@]}; do + wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$BROKER/$old_vsn/$PROFILE-ubuntu20.04-${old_vsn#[e|v]}-amd64.zip + done + - name: build emqx + run: make -C emqx ${PROFILE}-zip + - name: build emqtt-bench + run: make -C emqtt-bench + - name: build lux + run: | + set -e -u -x + cd lux + autoconf + ./configure + make + make install + - name: run relup test + run: | + set -e -x -u + if [ -n "$OLD_VSNS" ]; then + mkdir -p packages + cp emqx/_packages/emqx/*.zip packages + cp emqx/_upgrade_base/*.zip packages + lux -v \ + --timeout 600000 \ + --var PACKAGE_PATH=$(pwd)/packages \ + --var BENCH_PATH=$(pwd)/emqtt-bench \ + --var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \ + --var VSN="$VSN" \ + --var OLD_VSNS="$OLD_VSNS" \ + emqx/.ci/fvt_tests/relup.lux + fi + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: lux_logs + path: lux_logs + + + diff --git a/.github/workflows/run_gitlint.yaml b/.github/workflows/run_gitlint.yaml new file mode 100644 index 00000000..fa482b1c --- /dev/null +++ b/.github/workflows/run_gitlint.yaml @@ -0,0 +1,44 @@ +name: Run gitlint + +on: [pull_request] + +jobs: + run_gitlint: + runs-on: ubuntu-20.04 + steps: + - name: Checkout source code + uses: actions/checkout@master + - name: Install gitlint + run: | + sudo apt-get update + sudo apt install gitlint + - name: Set auth header + if: endsWith(github.repository, 'enterprise') + run: | + echo 'AUTH_HEADER<> $GITHUB_ENV + echo "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + - name: Run gitlint + shell: bash + run: | + pr_number=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + messages="$(curl --silent --show-error \ + --header "${{ env.AUTH_HEADER }}" \ + --header "Accept: application/vnd.github.v3+json" \ + "https://api.hub.fastgit.org/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/commits")" + len=$(echo $messages | jq length) + result=true + for i in $( seq 0 $(($len - 1)) ); do + message=$(echo $messages | jq -r .[$i].commit.message) + echo "commit message: $message" + status=0 + echo $message | gitlint -C ./.github/workflows/.gitlint || status=$? + if [ $status -ne 0 ]; then + result=false + fi + done + if ! ${result} ; then + echo "Some of the commit messages are not structured as The Conventional Commits specification. Please check CONTRIBUTING.md for our process on PR." + exit 1 + fi + echo "success" diff --git a/.github/workflows/run_test_cases.yaml b/.github/workflows/run_test_cases.yaml new file mode 100644 index 00000000..3680f7f9 --- /dev/null +++ b/.github/workflows/run_test_cases.yaml @@ -0,0 +1,154 @@ +name: Run test case + +on: + push: + tags: + - v* + - e* + release: + types: + - published + pull_request: + +jobs: + run_static_analysis: + runs-on: ubuntu-20.04 + container: emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04 + + steps: + - uses: actions/checkout@v2 + - name: set git credentials + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org" > $HOME/.git-credentials + git config --global credential.helper store + fi + - name: xref + run: make xref + - name: dialyzer + run: make dialyzer + + run_proper_test: + runs-on: ubuntu-20.04 + container: emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04 + + steps: + - uses: actions/checkout@v2 + - name: set git credentials + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org" > $HOME/.git-credentials + git config --global credential.helper store + fi + - name: proper + run: make proper + + run_common_test: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - name: set edition + id: set_edition + run: | + if make emqx-ee --dry-run > /dev/null 2>&1; then + echo "EDITION=enterprise" >> $GITHUB_ENV + else + echo "EDITION=opensource" >> $GITHUB_ENV + fi + - name: docker compose up + if: env.EDITION == 'opensource' + env: + MYSQL_TAG: 8 + REDIS_TAG: 6 + MONGO_TAG: 4 + PGSQL_TAG: 13 + LDAP_TAG: 2.4.50 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose.yaml \ + -f .ci/docker-compose-file/docker-compose-ldap-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-mongo-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-mysql-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-pgsql-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-redis-single-tcp.yaml \ + up -d --build + - name: docker compose up + if: env.EDITION == 'enterprise' + env: + MYSQL_TAG: 8 + REDIS_TAG: 6 + MONGO_TAG: 4 + PGSQL_TAG: 13 + LDAP_TAG: 2.4.50 + OPENTSDB_TAG: latest + INFLUXDB_TAG: 1.7.6 + DYNAMODB_TAG: 1.11.477 + TIMESCALE_TAG: latest-pg11 + CASSANDRA_TAG: 3.11.6 + RABBITMQ_TAG: 3.7 + KAFKA_TAG: 2.5.0 + PULSAR_TAG: 2.3.2 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + timeout-minutes: 20 + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose.yaml \ + -f .ci/docker-compose-file/docker-compose-ldap-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-mongo-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-mysql-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-pgsql-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-redis-single-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-cassandra-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-dynamodb-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-influxdb-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-kafka-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-opentsdb-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-pulsar-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-rabbit-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-timescale-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-mysql-client.yaml \ + -f .ci/docker-compose-file/docker-compose-enterprise-pgsql-and-timescale-client.yaml \ + up -d --build + docker exec -i erlang bash -c "echo \"https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@hub.fastgit.org\" > /root/.git-credentials && git config --global credential.helper store" + while [ $(docker ps -a --filter name=client --filter exited=0 | wc -l) \ + != $(docker ps -a --filter name=client | wc -l) ]; do + sleep 5 + done + - name: run eunit + run: | + docker exec -i erlang bash -c "make eunit" + - name: run common test + run: | + docker exec -i erlang bash -c "make ct" + - name: run cover + run: | + printenv > .env + docker exec -i erlang bash -c "make cover" + docker exec --env-file .env -i erlang bash -c "make coveralls" + - name: cat rebar.crashdump + if: failure() + run: if [ -f 'rebar3.crashdump' ];then cat 'rebar3.crashdump' fi + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: logs + path: _build/test/logs + - uses: actions/upload-artifact@v1 + with: + name: cover + path: _build/test/cover + + finish: + needs: run_common_test + runs-on: ubuntu-20.04 + steps: + - name: Coveralls Finished + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -v -k https://coveralls.io/webhook \ + --header "Content-Type: application/json" \ + --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true diff --git a/.github/workflows/shellcheck.yaml b/.github/workflows/shellcheck.yaml new file mode 100644 index 00000000..2084f386 --- /dev/null +++ b/.github/workflows/shellcheck.yaml @@ -0,0 +1,18 @@ +name: Shellcheck + +on: [pull_request] + +jobs: + shellcheck: + runs-on: ubuntu-20.04 + steps: + - name: Checkout source code + uses: actions/checkout@master + - name: Install shellcheck + run: | + sudo apt-get update + sudo apt install shellcheck + - name: Run shellcheck + run: | + ./scripts/shellcheck.sh + echo "success" diff --git a/.gitignore b/.gitignore index 1538ef27..218b2226 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,49 @@ .eunit +test-data/ deps +!deps/.placeholder *.o *.beam *.plt erl_crash.dump -rebar3.crashdump ebin -_rel/* +!ebin/.placeholder .concrete/DEV_MODE .rebar +test/ebin/*.beam +.exrc +plugins/*/ebin +*.swp +*.so .erlang.mk/ -etc/plugins/ -data/configs/*.config -data/configs/*.conf -data/configs/*.args -rel/ -log/ -ct/logs/* -.DS_Store +cover/ +eunit.coverdata +test/ct.cover.spec +ct.coverdata .idea/ -*.d -*.iml -vars.config -erlang.mk - -rebar.lock -test/ +_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.rendered +/rebar3 +rebar.lock +.stamp +tmp/ _packages -deploy/docker/tmp -.vscode/settings.json +elvis +emqx_dialyzer_*_plt +*/emqx_dashboard/priv/www +dist.zip +scripts/git-token +etc/*.seg +_upgrade_base/ diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..e7e734a7 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +erlang 23.2.7.2-emqx-1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..23f415db --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,82 @@ +# 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**: + +``` +(): + + + +