diff --git a/Makefile b/Makefile index 77cdfdef1..d9a44f484 100644 --- a/Makefile +++ b/Makefile @@ -14,11 +14,11 @@ dep_mochiweb = git https://github.com/emqtt/mochiweb.git ERLC_OPTS += +'{parse_transform, lager_transform}' EUNIT_OPTS = verbose -EUNIT_ERL_OPTS = -args_file rel/vm.args -config rel/sys.config +EUNIT_ERL_OPTS = -args_file test_data/ct_vm.args -config test_data/ct_sys.config CT_SUITES = emqttd emqttd_access emqttd_backend emqttd_lib emqttd_mod emqttd_net \ emqttd_mqueue emqttd_protocol emqttd_topic emqttd_trie -CT_OPTS = -cover test/ct.cover.spec -erl_args -name emqttd_ct@127.0.0.1 -config rel/sys.config +CT_OPTS = -cover test/ct.cover.spec -erl_args -name emqttd_ct@127.0.0.1 -config test_data/ct_sys.config COVER = true diff --git a/test_data/ct_emqttd.conf b/test_data/ct_emqttd.conf new file mode 100644 index 000000000..562bd908f --- /dev/null +++ b/test_data/ct_emqttd.conf @@ -0,0 +1,266 @@ +%%=================================================================== +%% +%% Config file for emqttd 2.0 +%% +%% Erlang Term Syntax: +%% +%% {}: Tuple, usually {Key, Value} +%% []: List, seperated by comma +%% %%: Comment +%% +%%=================================================================== + +%%-------------------------------------------------------------------- +%% MQTT Protocol +%%-------------------------------------------------------------------- + +%% Max ClientId Length Allowed. +{mqtt_max_clientid_len, 512}. + +%% Max Packet Size Allowed, 64K by default. +{mqtt_max_packet_size, 65536}. + +%% Client Idle Timeout. +{mqtt_client_idle_timeout, 30}. % Second + +%%-------------------------------------------------------------------- +%% Authentication +%%-------------------------------------------------------------------- + +%% Anonymous: Allow all +{auth, anonymous, []}. + +%% Authentication with username, password +{auth, username, []}. + +%% Authentication with clientId +{auth, clientid, [{password, no}]}. + +%%-------------------------------------------------------------------- +%% ACL +%%-------------------------------------------------------------------- + +{acl, anonymous, []}. + +{acl, internal, [{nomatch, allow}]}. + +%% Cache ACL result for PUBLISH +{cache_acl, true}. + +%%-------------------------------------------------------------------- +%% Broker +%%-------------------------------------------------------------------- + +%% System interval of publishing broker $SYS messages +{broker_sys_interval, 60}. + +%%-------------------------------------------------------------------- +%% Retained message +%%-------------------------------------------------------------------- + +%% Expired after seconds, never expired if 0 +{retained_expired_after, 0}. + +%% Max number of retained messages +{retained_max_message_num, 100000}. + +%% Max Payload Size of retained message +{retained_max_playload_size, 65536}. + +%%-------------------------------------------------------------------- +%% Session +%%-------------------------------------------------------------------- + +%% Max number of QoS 1 and 2 messages that can be “inflight” at one time. +%% 0 means no limit +{session_max_inflight, 100}. + +%% Retry interval for redelivering QoS1/2 messages. +{session_unack_retry_interval, 60}. + +%% Awaiting PUBREL Timeout +{session_await_rel_timeout, 20}. + +%% Max Packets that Awaiting PUBREL, 0 means no limit +{session_max_awaiting_rel, 0}. + +%% Statistics Collection Interval(seconds) +{session_collect_interval, 0}. + +%% Expired after 2 day (unit: minute) +{session_expired_after, 2880}. + +%%-------------------------------------------------------------------- +%% Queue +%%-------------------------------------------------------------------- + +%% Type: simple | priority +{queue_type, simple}. + +%% Topic Priority: 0~255, Default is 0 +%% {queue_priority, [{"topic/1", 10}, {"topic/2", 8}]}. + +%% Max queue length. Enqueued messages when persistent client disconnected, +%% or inflight window is full. +{queue_max_length, infinity}. + +%% Low-water mark of queued messages +{queue_low_watermark, 0.2}. + +%% High-water mark of queued messages +{queue_high_watermark, 0.6}. + +%% Queue Qos0 messages? +{queue_qos0, true}. + +%%-------------------------------------------------------------------- +%% Zone +%%-------------------------------------------------------------------- + +{zone, admin, []}. + +%%-------------------------------------------------------------------- +%% Listener +%%-------------------------------------------------------------------- + +%% Plain MQTT +{listener, mqtt, 1883, [ + %% Size of acceptor pool + {acceptors, 16}, + + %% Maximum number of concurrent clients + {max_clients, 512}, + + %% Mount point prefix + %% {mount_point, "prefix/"}, + + %% Socket Access Control + {access, [{allow, all}]}, + + %% Connection Options + {connopts, [ + %% Rate Limit. Format is 'burst, rate', Unit is KB/Sec + %% {rate_limit, "100,10"} %% 100K burst, 10K rate + ]}, + + %% Socket Options + {sockopts, [ + %Set buffer if hight thoughtput + %{recbuf, 4096}, + %{sndbuf, 4096}, + %{buffer, 4096}, + %{nodelay, true}, + {backlog, 1024} + ]} +]}. + +%% MQTT/SSL +{listener, mqtts, 8883, [ + %% Size of acceptor pool + {acceptors, 4}, + + %% Maximum number of concurrent clients + {max_clients, 512}, + + %% Socket Access Control + {access, [{allow, all}]}, + + %% SSL certificate and key files + {ssl, [{certfile, "etc/ssl/ssl.crt"}, + {keyfile, "etc/ssl/ssl.key"}]}, + + %% Socket Options + {sockopts, [ + {backlog, 1024} + %{buffer, 4096}, + ]} +]}. + +%% HTTP and WebSocket Listener +{listener, http, 8083, [ + %% Size of acceptor pool + {acceptors, 4}, + + %% Maximum number of concurrent clients + {max_clients, 64}, + + %% Socket Access Control + {access, [{allow, all}]}, + + %% Socket Options + {sockopts, [ + {backlog, 1024} + %{buffer, 4096}, + ]} +]}. + +%%-------------------------------------------------------------------- +%% PubSub +%%-------------------------------------------------------------------- + +%% PubSub and Router. Default should be scheduler numbers. +{pubsub_pool_size, 8}. + +%%-------------------------------------------------------------------- +%% Routing +%%-------------------------------------------------------------------- + +%% Route aging time(seconds) +{routing_age, 5}. + +%%-------------------------------------------------------------------- +%% Bridge +%%-------------------------------------------------------------------- + +%% TODO: Bridge Queue Size +{bridge_max_queue_len, 10000}. + +%% Ping Interval of bridge node +{bridge_ping_down_interval, 1}. % second + +%%------------------------------------------------------------------- +%% Plugins +%%------------------------------------------------------------------- + +%% Dir of plugins' config +{plugins_etc_dir, "etc/plugins/"}. + +%% File to store loaded plugin names. +{plugins_loaded_file, "data/loaded_plugins"}. + +%%-------------------------------------------------------------------- +%% Modules +%%-------------------------------------------------------------------- + +%% Client presence management module. Publish presence messages when +%% client connected or disconnected. +{module, presence, [{qos, 0}]}. + +%% Subscribe topics automatically when client connected +{module, subscription, [{"$queue/clients/$c", 1}, backend]}. + +%% [Rewrite](https://github.com/emqtt/emqttd/wiki/Rewrite) +{module, rewrite, []}. + +%%------------------------------------------------------------------- +%% Erlang System Monitor +%%------------------------------------------------------------------- + +%% Long GC, don't monitor in production mode for: +%% https://github.com/erlang/otp/blob/feb45017da36be78d4c5784d758ede619fa7bfd3/erts/emulator/beam/erl_gc.c#L421 + +{sysmon_long_gc, false}. + +%% Long Schedule(ms) +{sysmon_long_schedule, 240}. + +%% 8M words. 32MB on 32-bit VM, 64MB on 64-bit VM. +%% 8 * 1024 * 1024 +{sysmon_large_heap, 8388608}. + +%% Busy Port +{sysmon_busy_port, false}. + +%% Busy Dist Port +{sysmon_busy_dist_port, true}. + diff --git a/test_data/ct_sys.config b/test_data/ct_sys.config new file mode 100644 index 000000000..bce791354 --- /dev/null +++ b/test_data/ct_sys.config @@ -0,0 +1,6 @@ +% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ft=erlang ts=4 sw=4 et +[ + {kernel, [{start_timer, true}, {start_pg2, true}]}, + {emqttd, [{conf, "test_data/emqttd_ct.conf"}]} +]. diff --git a/test_data/ct_vm.args b/test_data/ct_vm.args new file mode 100644 index 000000000..e05e373a4 --- /dev/null +++ b/test_data/ct_vm.args @@ -0,0 +1,61 @@ +##------------------------------------------------------------------------- +## Name of the emqttd node: Name@Host +## +## NOTICE: The Host should be IP address or the fully qualified host name. +## The short hostname cannot work! +##------------------------------------------------------------------------- + +-name emqttd_ct@127.0.0.1 +# or +#-name emqttd@localhost. + +## Cookie for distributed erlang +-setcookie emqttdsecretcookie + +##------------------------------------------------------------------------- +## Flags +##------------------------------------------------------------------------- + +## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive +## (Disabled by default..use with caution!) +##-heart +-smp true + +## Enable kernel poll and a few async threads ++K true + +## 12 threads/core. ++A 24 + +## max process numbers +#+P 8192 + +## Sets the maximum number of simultaneously existing ports for this system +#+Q 8192 + +## max atom number +## +t + +## Set the distribution buffer busy limit (dist_buf_busy_limit) in kilobytes. +## Valid range is 1-2097151. Default is 1024. +## +zdbbl 8192 + +## Set scheduler bind type. +## +sbt db + +##------------------------------------------------------------------------- +## Env +##------------------------------------------------------------------------- + +## Increase number of concurrent ports/sockets, deprecated in R17 +#-env ERL_MAX_PORTS 8192 + +#-env ERTS_MAX_PORTS 8192 + +## Mnesia and SSL will create temporary ets tables. +-env ERL_MAX_ETS_TABLES 1024 + +## Tweak GC to run more often +-env ERL_FULLSWEEP_AFTER 1000 + +-env ERL_CRASH_DUMP log/emqttd_crash.dump